Uploaded image for project: 'Shiro'
  1. Shiro
  2. SHIRO-482

EhCache API misuse prevents use of decorated caches

    XMLWordPrintableJSON

Details

    • Bug
    • Status: Open
    • Major
    • Resolution: Unresolved
    • None
    • None
    • Caching
    • 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);

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

      Attachments

        Activity

          People

            Unassigned Unassigned
            cstamas Tamas Cservenak
            Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

            Dates

              Created:
              Updated: