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

EhCache API misuse prevents use of decorated caches

Agile BoardAttach filesAttach ScreenshotAdd voteVotersWatch issueWatchersCreate sub-taskLinkCloneUpdate Comment AuthorReplace String in CommentUpdate Comment VisibilityDelete Comments
    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

          This comment will be Viewable by All Users Viewable by All Users
          Cancel

          People

            Unassigned Unassigned
            cstamas Tamas Cservenak

            Dates

              Created:
              Updated:

              Slack

                Issue deployment