[ 
https://issues.apache.org/jira/browse/SHIRO-482?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel
 ]

Cservenak, Tamas updated SHIRO-482:
-----------------------------------

    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);



[1] http://ehcache.org/documentation/apis/cache-decorators

  was:
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.

Proposed fix: one liner change of line 162 that currently yields

cache = manager.getCache(name);

to 

cache = manager.getEhcache(name);



[1] http://ehcache.org/documentation/apis/cache-decorators


> EhCache API misuse prevents use of decorated caches
> ---------------------------------------------------
>
>                 Key: SHIRO-482
>                 URL: https://issues.apache.org/jira/browse/SHIRO-482
>             Project: Shiro
>          Issue Type: Bug
>          Components: Caching 
>            Reporter: Cservenak, Tamas
>
> 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);
> [1] http://ehcache.org/documentation/apis/cache-decorators



--
This message was sent by Atlassian JIRA
(v6.1.5#6160)

Reply via email to