Spring cache defaults to hashcode based cache key for multiple arguments [SPR-10688] #15316
Labels
in: core
Issues in core modules (aop, beans, core, context, expression)
status: duplicate
A duplicate of another issue
Uh oh!
There was an error while loading. Please reload this page.
Lance S opened SPR-10688 and commented
If I add a
@Cacheable
("cachename") annotation to a method with multiple arguments and I don't specify a key, Spring will create a cache key for me. This cache key is a hash of the arguments. Since a hash is not guaranteed to be unique, I think that this is a dangerous default which will cause errors (although the errors will be rare).For example:
Long.valueOf(0) and Long.valueOf(-1) both have 0 as their hashcode.
I have attached a failing test case. The test case fails the final assertion
Attachments:
Issue Links:
The text was updated successfully, but these errors were encountered: