-
Notifications
You must be signed in to change notification settings - Fork 38.8k
Description
Alexander Derenbach opened SPR-8933 and commented
When I read the reference documentation I thought the caching abstraction is on method level, but it seems it is only on the parameter value of the methods.
If I have several methods with the same parameter type it get always the same return value:
@Component
public class CacheTestImpl implements CacheTest {
@Cacheable
("databaseCache")
public Long test1() {
return 1L;
}
@Cacheable("databaseCache")
public Long test2() {
return 2L;
}
@Cacheable("databaseCache")
public Long test3() {
return 3L;
}
@Cacheable("databaseCache")
public String test4() {
return "4";
}
}
Calling now:
System.out.println(test.test1());
System.out.println(test.test2());
System.out.println(test.test3());
System.out.println(test.test4());
results in:
1
1
1
ClassCastException: java.lang.Long cannot be cast to java.lang.String
Is this the desired behaviour? I would expect:
1
2
3
4
If I use different caches it works.
I can't access github from my place (firewall) so I have added a tar with a small maven project showing this problem.
Greets Alex
Affects: 3.1 GA
Attachments:
- cacheproblem.tar (70.00 kB)
- MethodAwareCacheKeyGenerator.java (455 bytes)
Issue Links:
- Cacheable javadoc wrongly explains how cache keys are generated [SPR-11736] #16358 Cacheable javadoc wrongly explains how cache keys are generated
5 votes, 9 watchers