You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Since Java 8 it is VERY IMPORTANT to always make your custom keys for HashMap implement Comparable. HashMap now puts your entries into a tree to avoid degradation to O(n) when the entries map to the same bucket. It somehow needs to know the relative order of the keys. If they are strings, then comparing them is trivial. Otherwise, if the key class implements Comparable it uses the compareTo() function. If not, it will eventually use System.identityHashCode() to determine the sort order.
All custom cache key classes within the core codebase (there aren't that many, actually) implement Comparable in a reasonably efficient way now, and also consistently provide a toString representation (primarily for debugging views).
Due to the rather involved nature of efficient compareTo handling and our focus on consistent toString support, it also makes more sense to reuse key classes now, rather than individual inner classes as before. As a consequence, I've introduced org.springframework.core.MethodClassKey which gets reused across our cache and transaction attribute sources now; it is basically what the transaction attribute source was using before, now identically used for our two cache attribute sources instead of the more generic AnnotatedElementKey (with a less sophisticated compareTo implementation). As a side bonus, this also reduces our dependencies on the context.expression package (where AnnotatedElementKey is defined) to places already using context.expression for other reasons.
Juergen Hoeller opened SPR-14017 and commented
According to http://www.javaspecialists.eu/archive/Issue235.html...
No further details from SPR-14017
The text was updated successfully, but these errors were encountered: