Details
-
Bug
-
Status: Open
-
Major
-
Resolution: Unresolved
-
None
-
None
-
None
Description
Shiro's EhCacheManager poses some implicit requirements against Caches served by EHCache CacheManager. Most notable, that EHCache manager instance registered by CacheManager is also a net.sf.ehcache.Cache instance. This can be seen in getCache method of EhCacheManager, as it uses CacheManager.getCache(String) method instead of CacheManager.getEhcache(String) method to populate local variable "cache" of type net.sf.ehcache.Ehcache.
This condition is not always true, especially when "cache decoration" [1] feature of EHCache is used. In that case, CacheManager.getCache(String) will return null (as decorated cache will probably not be an instance of Cache), and NPE will happen when creation of org.apache.shiro.cache.ehcache.EhCache is attempted with null Cache.
Proposed fix: one liner change of line 162 that currently yields
cache = manager.getCache(name);
to
cache = manager.getEhcache(name);