Fix build by reinstating Guava dependency#83
Conversation
This fixes an error caused by conflicting merges. A PR added new code which depended on Guava while another deleted the dependency. The commit adds the dependency rather than updating the code to not require the dependency because my understanding is that Guava immutable sets provide better guarantees than Java unmodifiable collections. Specifically, if a reference is kept to the set used to construct an unmodifiable set, then any mutation to that set is reflected in the unmodifiable set. The Guava immutable set creates a copy.
|
Just to provide some additional perspective, Guava is a 3 MB JAR, which is rather large considering the minimal use within the Cedar Java library. It is correct that I did not notice this feature when submitting the pull request to remove Guava, so thanks for highlighting the differences. Under the hood, the Guava Thanks for the consideration. |
cdisselkoen
left a comment
There was a problem hiding this comment.
Merging this now to unbreak CI is expedient, and then we can continue the discussion of the Guava dependency
This fixes an error caused by conflicting merges. A PR added new code which depended on Guava while another deleted the dependency.
The commit adds the dependency rather than updating the code to not require the dependency because my understanding is that Guava immutable sets provide better guarantees than Java unmodifiable collections. Specifically, unmodifiable sets hold a reference to the set used in their construction. If a reference is kept to the set used to construct an unmodifiable set, then any mutation to that set is reflected in the unmodifiable set. The Guava immutable set creates a copy.
In any case where we store the set in a field of an object, we should use guava immutable types. When returning a collection, we can use the builtin unmodifiable methods to avoid copying the data.