svn commit: r929398 - in /ofbiz/trunk/framework/base/src/org/ofbiz/base/util/cache: CacheLineTable.java test/UtilCacheTests.java

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
1 message Options
Reply | Threaded
Open this post in threaded view
|

svn commit: r929398 - in /ofbiz/trunk/framework/base/src/org/ofbiz/base/util/cache: CacheLineTable.java test/UtilCacheTests.java

doogie-3
Author: doogie
Date: Wed Mar 31 06:10:14 2010
New Revision: 929398

URL: http://svn.apache.org/viewvc?rev=929398&view=rev
Log:
Fetching null key from disk when it doesn't already exist in memory was
broken, because the key wasn't protected with ObjectType.NULL.

Modified:
    ofbiz/trunk/framework/base/src/org/ofbiz/base/util/cache/CacheLineTable.java
    ofbiz/trunk/framework/base/src/org/ofbiz/base/util/cache/test/UtilCacheTests.java

Modified: ofbiz/trunk/framework/base/src/org/ofbiz/base/util/cache/CacheLineTable.java
URL: http://svn.apache.org/viewvc/ofbiz/trunk/framework/base/src/org/ofbiz/base/util/cache/CacheLineTable.java?rev=929398&r1=929397&r2=929398&view=diff
==============================================================================
--- ofbiz/trunk/framework/base/src/org/ofbiz/base/util/cache/CacheLineTable.java (original)
+++ ofbiz/trunk/framework/base/src/org/ofbiz/base/util/cache/CacheLineTable.java Wed Mar 31 06:10:14 2010
@@ -133,7 +133,7 @@ public class CacheLineTable<K, V> implem
         }
         if (fileTable != null) {
             try {
-                if (oldValue == null) oldValue = getFileTable(key);
+                if (oldValue == null) oldValue = getFileTable(key != null ? key : ObjectType.NULL);
                 fileTable.put(key != null ? key : ObjectType.NULL, value);
                 CacheLineTable.jdbmMgr.commit();
             } catch (IOException e) {

Modified: ofbiz/trunk/framework/base/src/org/ofbiz/base/util/cache/test/UtilCacheTests.java
URL: http://svn.apache.org/viewvc/ofbiz/trunk/framework/base/src/org/ofbiz/base/util/cache/test/UtilCacheTests.java?rev=929398&r1=929397&r2=929398&view=diff
==============================================================================
--- ofbiz/trunk/framework/base/src/org/ofbiz/base/util/cache/test/UtilCacheTests.java (original)
+++ ofbiz/trunk/framework/base/src/org/ofbiz/base/util/cache/test/UtilCacheTests.java Wed Mar 31 06:10:14 2010
@@ -252,7 +252,6 @@ public class UtilCacheTests extends Gene
             assertNoSingleKey(cache, "one");
             long origByteSize = cache.getSizeInBytes();
 
-            /*
             wantedListener.noteKeyAddition(cache, null, "null");
             assertNull("put", cache.put(null, "null"));
             assertHasSingleKey(cache, null, "null");
@@ -262,7 +261,6 @@ public class UtilCacheTests extends Gene
             wantedListener.noteKeyRemoval(cache, null, "null");
             assertEquals("remove", "null", cache.remove(null));
             assertNoSingleKey(cache, null);
-            */
 
             wantedListener.noteKeyAddition(cache, "one", "uno");
             assertNull("put", cache.put("one", "uno"));
@@ -305,11 +303,11 @@ public class UtilCacheTests extends Gene
             assertNoSingleKey(cache, "one");
         }
 
-        assertEquals("get-miss", 8, cache.getMissCountNotFound());
-        assertEquals("get-miss-total", 8, cache.getMissCountTotal());
-        assertEquals("get-hit", 20, cache.getHitCount());
-        assertEquals("remove-hit", 4, cache.getRemoveHitCount());
-        assertEquals("remove-miss", 8, cache.getRemoveMissCount());
+        assertEquals("get-miss", 10, cache.getMissCountNotFound());
+        assertEquals("get-miss-total", 10, cache.getMissCountTotal());
+        assertEquals("get-hit", 24, cache.getHitCount());
+        assertEquals("remove-hit", 6, cache.getRemoveHitCount());
+        assertEquals("remove-miss", 10, cache.getRemoveMissCount());
         cache.removeListener(gotListener);
         assertEquals("listener", wantedListener, gotListener);
         cache.clear();