Skip to content

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

@spring-projects-issues

Description

@spring-projects-issues

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:

Metadata

Metadata

Assignees

Labels

in: coreIssues in core modules (aop, beans, core, context, expression)type: bugA general bug

Type

No type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions