You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@cayenne.apache.org by "Andrus Adamchik (JIRA)" <ji...@apache.org> on 2012/11/22 12:08:57 UTC

[jira] [Updated] (CAY-1774) EhCacheQueryCache.get(QueryMetadata, QueryCacheEntryFactory) returns null if EhCache instance for group is not present

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

Andrus Adamchik updated CAY-1774:
---------------------------------

    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.


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

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.

    
> EhCacheQueryCache.get(QueryMetadata, QueryCacheEntryFactory) returns null if EhCache instance for group is not present
> ----------------------------------------------------------------------------------------------------------------------
>
>                 Key: CAY-1774
>                 URL: https://issues.apache.org/jira/browse/CAY-1774
>             Project: Cayenne
>          Issue Type: Bug
>          Components: Core Library
>    Affects Versions: 3.1B1
>            Reporter: Andrus Adamchik
>            Assignee: Andrus Adamchik
>            Priority: Minor
>             Fix For: 3.1B2, 3.2M1
>
>
> 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.

--
This message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators
For more information on JIRA, see: http://www.atlassian.com/software/jira