Uploaded image for project: 'Cayenne'
  1. Cayenne
  2. CAY-1774

EhCacheQueryCache.get(QueryMetadata, QueryCacheEntryFactory) returns null if EhCache instance for group is not present

    XMLWordPrintableJSON

Details

    • Bug
    • Status: Closed
    • Minor
    • Resolution: Fixed
    • 3.1B1
    • 3.1B2, 3.2.M1
    • Core Library
    • None

    Description

      Here is a problematic piece of code:

      public List get(QueryMetadata metadata, QueryCacheEntryFactory factory) {
      String key = metadata.getCacheKey();
      if (key == null)

      { return null; }

      Ehcache cache = null;
      Element result = null;
      String[] groupNames = metadata.getCacheGroups();
      if (groupNames != null && groupNames.length > 0) {

      // SHOULD WE USE 'addCacheIfAbsent' here, as we already have a factory to populate object???
      cache = cacheManager.getCache(groupNames[0]);
      if (cache == null)

      { return null; }

      ....

      Sure enough there is a workaround of declaring all cache groups as "caches" within ehcache.xml, so this issue may be about usability and consistency after all ('put' for instance uses 'addCacheIfAbsent', but not 'get' with factory).

      Also maybe we can refactor calls to 'get' and 'put' within this method to avoid multiple cache lookups, when we already have a cache instance in place.

      Attachments

        Activity

          People

            andrus Andrus Adamchik
            andrus Andrus Adamchik
            Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved: