Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Gh-308: Remove Guava dependency #309

Closed
wants to merge 4 commits into from

Conversation

GCHQDeveloper314
Copy link
Member

@GCHQDeveloper314 GCHQDeveloper314 commented Apr 7, 2023

@codecov-commenter
Copy link

codecov-commenter commented Apr 7, 2023

Codecov Report

Merging #309 (ca152d0) into develop (5b167b0) will decrease coverage by 0.05%.
The diff coverage is 86.66%.

📣 This organization is not using Codecov’s GitHub App Integration. We recommend you install it so Codecov can continue to function properly for your repositories. Learn more

@@              Coverage Diff              @@
##             develop     #309      +/-   ##
=============================================
- Coverage      82.20%   82.15%   -0.05%     
- Complexity      1618     1626       +8     
=============================================
  Files            194      194              
  Lines           4326     4338      +12     
  Branches         436      436              
=============================================
+ Hits            3556     3564       +8     
- Misses           591      594       +3     
- Partials         179      180       +1     
Impacted Files Coverage Δ
.../java/uk/gov/gchq/koryphe/util/ReflectionUtil.java 80.00% <0.00%> (ø)
...in/java/uk/gov/gchq/koryphe/util/IterableUtil.java 75.00% <71.42%> (-5.00%) ⬇️
...ryphe/serialisation/json/SimpleClassNameCache.java 68.61% <75.00%> (ø)
...a/uk/gov/gchq/koryphe/impl/function/FirstItem.java 100.00% <100.00%> (ø)
.../uk/gov/gchq/koryphe/impl/function/FirstValid.java 100.00% <100.00%> (ø)
.../gov/gchq/koryphe/impl/function/FunctionChain.java 100.00% <100.00%> (ø)
...ava/uk/gov/gchq/koryphe/impl/function/IsEmpty.java 100.00% <100.00%> (ø)
...va/uk/gov/gchq/koryphe/impl/function/LastItem.java 100.00% <100.00%> (ø)
...java/uk/gov/gchq/koryphe/impl/function/Length.java 98.00% <100.00%> (ø)
...ava/uk/gov/gchq/koryphe/impl/function/NthItem.java 100.00% <100.00%> (ø)
... and 14 more

Help us with your feedback. Take ten seconds to tell us how you rate us. Have a feature suggestion? Share it here.

Copy link
Member Author

@GCHQDeveloper314 GCHQDeveloper314 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Draft because IterableUtil.java needs new unit tests adding.

These changes should also be tested with Gaffer before being merged as there's a potential that some untested behaviours (e.g. Null handling, unmodifiable) have changed compared to when Guava methods were used.

@@ -53,7 +53,7 @@ public T apply(final Iterable<T> input) {
throw new IllegalArgumentException("Input cannot be null");
}
try {
return Iterables.get(input, selection);
return IterableUtil.toList(input).get(selection);
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This approach could be less efficient, depending on how Guava implements it.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is guava's implementation. Ideally we will want to do something similar as converting to a list will be less efficient if the underlying object is not a List itself.

@@ -366,7 +367,7 @@ private static void addSimpleClassNames(final Map<String, Set<Class>> map, final
final String id = StringUtils.capitalize(entry.getKey());
final Set<Class> value = map.get(id);
if (null == value) {
map.put(id, Sets.newHashSet(entry.getValue()));
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Did this create a new Set before to effectively set by value rather than reference?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It created a new set which was a copy of the old one. There's some similar code somewhere else which didn't make a copy so I just removed the copy.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I just worry this would change functionality as it now sets by reference not by value? Could make a new unit test?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could do, though if you're concerned it would be easiest to change it back to creating a copy.

pom.xml Show resolved Hide resolved
@GCHQDeveloper314
Copy link
Member Author

Further work is needed and ideally Java 8 support should be dropped first, as it would be much easier to replace some methods by moving to Java 11 where they are built in.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Investigate removing dependency on Guava
3 participants