commons-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From t.@apache.org
Subject svn commit: r1157587 - /commons/proper/jcs/trunk/src/java/org/apache/jcs/engine/memory/lru/LHMLRUMemoryCache.java
Date Sun, 14 Aug 2011 18:07:54 GMT
Author: tv
Date: Sun Aug 14 18:07:54 2011
New Revision: 1157587

URL: http://svn.apache.org/viewvc?rev=1157587&view=rev
Log:
Fixed NPE on access

Modified:
    commons/proper/jcs/trunk/src/java/org/apache/jcs/engine/memory/lru/LHMLRUMemoryCache.java

Modified: commons/proper/jcs/trunk/src/java/org/apache/jcs/engine/memory/lru/LHMLRUMemoryCache.java
URL: http://svn.apache.org/viewvc/commons/proper/jcs/trunk/src/java/org/apache/jcs/engine/memory/lru/LHMLRUMemoryCache.java?rev=1157587&r1=1157586&r2=1157587&view=diff
==============================================================================
--- commons/proper/jcs/trunk/src/java/org/apache/jcs/engine/memory/lru/LHMLRUMemoryCache.java
(original)
+++ commons/proper/jcs/trunk/src/java/org/apache/jcs/engine/memory/lru/LHMLRUMemoryCache.java
Sun Aug 14 18:07:54 2011
@@ -125,23 +125,24 @@ public class LHMLRUMemoryCache
     public synchronized ICacheElement get( Serializable key )
         throws IOException
     {
-        ICacheElement ce = null;
+        MemoryElementDescriptor me = null;
 
         if ( log.isDebugEnabled() )
         {
             log.debug( "getting item from cache " + cacheName + " for key " + key );
         }
 
-        ce = map.get( key ).ce;
+        me = map.get( key );
 
-        if ( ce != null )
+        if ( me != null )
         {
             hitCnt++;
-            ce.getElementAttributes().setLastAccessTimeNow();
+            me.ce.getElementAttributes().setLastAccessTimeNow();
             if ( log.isDebugEnabled() )
             {
                 log.debug( cacheName + ": LRUMemoryCache hit for " + key );
             }
+            return me.ce;
         }
         else
         {
@@ -149,7 +150,7 @@ public class LHMLRUMemoryCache
             log.debug( cacheName + ": LRUMemoryCache miss for " + key );
         }
 
-        return ce;
+        return null;
     }
 
     /**



Mime
View raw message