Skip to content

Caching Abstraction ignores method name? [SPR-8933] #13573

@spring-projects-issues

Description

@spring-projects-issues

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:

Issue Links:

5 votes, 9 watchers

Metadata

Metadata

Assignees

Labels

in: coreIssues in core modules (aop, beans, core, context, expression)status: declinedA suggestion or change that we don't feel we should currently apply

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions