Replace constant hashcode#3832
Conversation
249ac2d to
cf722a1
Compare
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #3832 +/- ##
============================================
- Coverage 86.84% 86.82% -0.02%
- Complexity 3044 3048 +4
============================================
Files 344 344
Lines 9172 9183 +11
Branches 1135 1139 +4
============================================
+ Hits 7965 7973 +8
+ Misses 917 915 -2
- Partials 290 295 +5 ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
|
If I remember correctly, the problem is hashing class identity. This will break with serialization. Serializing on strings should be fine, though, that's a thing we should certainly improve. |
You're right, and I learned something here 😄 I've changed it to hash on the class names instead of the Class objects to achieve a portable hashCode implementation. The equals contract still holds: equal methods resolve to the same classes and therefore the same names. Thanks for the catch! Let me know your thoughts. |
A few classes (InterceptedInvocation, SerializableMethod, Equals) returned a constant number (1) as their hashcode implementation, collapsing every instance into one bucket and degrading HashMap/HashSet lookups to linear complexity.
This PR fixes it (and removes corresponding
TODOfrom the code) so that each hashcode derives from the same fields taken into consideration for their equals.Checklist
including project members to get a better picture of the change
commit is meaningful and help the people that will explore a change in 2 years
./gradlew spotlessApplyfor auto-formatting)Fixes #<issue number>in the description if relevantFixes #<issue number>if relevant