Skip to content
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

Cache.get(key, type) doesn't work in case of null value found in cache [SPR-11567] #16191

Closed
spring-projects-issues opened this issue Mar 17, 2014 · 1 comment
Assignees
Labels
in: core type: bug
Milestone

Comments

@spring-projects-issues
Copy link
Collaborator

@spring-projects-issues spring-projects-issues commented Mar 17, 2014

Jan Novotný opened SPR-11567 and commented

There is probably unwanted behaviour coded in class org.springframework.cache.ehcache.EhCacheCache in method org.springframework.cache.ehcache.EhCacheCache#get(java.lang.Object, java.lang.Class<T>). When there is no value cached (ie. value == null) there is no way this check could pass:

if (type != null && !type.isInstance(value)) {
throw new IllegalStateException("Cached value is not of required type [" + type.getName() + "]: " + value);
}

And this leads to unexpected Illegal state exceptions in expected situations when caches are empty.


Affects: 4.0.2

Issue Links:

  • #15688 Add org.springframework.cache.Cache.get(key, type)
@spring-projects-issues
Copy link
Collaborator Author

@spring-projects-issues spring-projects-issues commented Mar 17, 2014

Juergen Hoeller commented

This is indeed an accident, and applies not only to EhCacheCache but to all our implementations of the Cache interface... Fixed for 4.0.3 now.

Juergen

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
in: core type: bug
Projects
None yet
Development

No branches or pull requests

2 participants