Open callum-kilby opened 3 years ago
Thank you for your report, I will add ImmutableMap & co. to the list of immutable objects. (Unfortunately I cannot assign this bug to myself since I am not yet an official project member.)
Just a side note: Either make this an issue (https://github.com/spotbugs/spotbugs/issues) or move this discussion to here: https://github.com/spotbugs/spotbugs/discussions.
:+1: thanks very much, I've created an issue with the same description here: https://github.com/spotbugs/spotbugs/issues/1601
We are using Guava Immutable objects in our project, and from SpotBugs 4.3.0 we have SpotBugs failures EI_EXPOSE_REP and EI_EXPOSE_REP2 when directly setting/retrieving class fields as Immutable objects.
For example:
results in an EI_EXPOSE_REP2 failure from
this.overrides = overrides
.This failure is incorrect because the object being passed in and set for the class field is shallowly immutable. What can be done to fix these failures? I'm hoping we don't need to completely exclude EI_EXPOSE_REP and EI_EXPOSE_REP2, or annotate everywhere we do something like this.