Skip to content

@Cacheable not working on interface method in Spring Boot 1.4.2+ #8331

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
ahmednasir91 opened this issue Feb 20, 2017 · 5 comments
Closed

@Cacheable not working on interface method in Spring Boot 1.4.2+ #8331

ahmednasir91 opened this issue Feb 20, 2017 · 5 comments
Labels
status: duplicate A duplicate of another issue

Comments

@ahmednasir91
Copy link

We use Spring cache annotation

@Cacheable(cacheManager = "cacheManager", value = "cache-test", key = "'test-key2'")

This used to work well till Spring Boot 1.4.1 and the interface methods are annotated, since after upgrading to Spring Boot 1.4.3 & also tried the same on 1.4.4 the interface annotated methods have stopped working.

After digging deeper, we found it stops working with Spring Data JPA

<dependency>
	<groupId>org.springframework.boot</groupId>
	<artifactId>spring-boot-starter-data-jpa</artifactId>
</dependency>

If you exclude this repo, it starts working on interface methods.

This is the sample repo, to reproduce the issue https://github.com/ahmednasir91/spring-cache-test
The project has 3 branches

  • master SB v1.4.4 & Data JPA commented - Caching works on interface methods
  • cache-not-working SB 1.4.4, Data JPA enabled - Caching doesn't work for interface method
  • working-boot-1.4.1 SB 1.4.1 Data JPA enabled - Caching works on interface methods

Following are the APIs

These two have caching on interface
GET /test/hello2 
GET /test/hello

This one has on implementation
GET /test/hello-list
@ahmednasir91 ahmednasir91 changed the title @Cacheable not working on interface in Spring Boot 1.4.3+ @Cacheable not working on interface method in Spring Boot 1.4.3+ Feb 20, 2017
@spring-projects-issues spring-projects-issues added the status: waiting-for-triage An issue we've not yet triaged label Feb 20, 2017
@snicoll snicoll changed the title @Cacheable not working on interface method in Spring Boot 1.4.3+ @Cacheable not working on interface method in Spring Boot 1.4.2+ Feb 20, 2017
@snicoll
Copy link
Member

snicoll commented Feb 20, 2017

Thanks for the sample but I've built something that is more reasonable based on yours (you really do not need a redis store to reproduce this issue!)

https://github.com/snicoll-scratches/test-cache-interface

The mix between annotations on interface and concrete classes is not something we recommend doing but I can confirm that adding the JPA starter is enough to trigger the problem. It works with Spring Boot 1.4.1..RELEASE (Spring Framework 4.3.3.RELEASE) and does not anymore as of 1.4.2.RELEASE (Spring Framework 4.3.4.RELEASE).

If I upgrade the spring framework version to use with 1.4.1.RELEASE with 4.3.4.RELEASE I am able to reproduce the problem. This looks like a framework regression but I have no idea why data jpa is triggering it.

@snicoll snicoll added priority: high type: regression A regression from a previous release and removed status: waiting-for-triage An issue we've not yet triaged labels Feb 20, 2017
@snicoll snicoll added this to the 1.4.5 milestone Feb 20, 2017
@ahmednasir91
Copy link
Author

ahmednasir91 commented Feb 20, 2017

Thanks @snicoll

We are using @Cacheable on interfaces only, just for sample i added to both interfaces & concrete class.

@snicoll
Copy link
Member

snicoll commented Feb 20, 2017

Ah that makes sense, thanks for clarifying.

@snicoll
Copy link
Member

snicoll commented Feb 20, 2017

After further investigation, this has been confirmed as a regression in Spring Framework, watch SPR-15271 for updates. I am closing this one in favour of #8248

@snicoll snicoll closed this as completed Feb 20, 2017
@snicoll snicoll added status: duplicate A duplicate of another issue and removed priority: high type: regression A regression from a previous release labels Feb 20, 2017
@snicoll snicoll removed this from the 1.4.5 milestone Feb 20, 2017
@rcollette

This comment has been minimized.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
status: duplicate A duplicate of another issue
Projects
None yet
Development

No branches or pull requests

4 participants