You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@ofbiz.apache.org by jl...@apache.org on 2009/11/19 09:25:55 UTC

svn commit: r882072 - /ofbiz/trunk/framework/base/src/org/ofbiz/base/util/cache/CacheLineTable.java

Author: jleroux
Date: Thu Nov 19 08:25:48 2009
New Revision: 882072

URL: http://svn.apache.org/viewvc?rev=882072&view=rev
Log:
A patch from Philippe Mouawad "OutOfMemory provoked by Cache overflow" (https://issues.apache.org/jira/browse/OFBIZ-2186) - OFBIZ-2186

CacheLineTable and LRUMap do not synchronize on the same lock

    * CacheLineTable synchronization use the CacheLineTable instance monitor
    * LRUMap synchronization use the LRUMap instance monitor

the LRUMap (memoryTable) can be updated concurrently by 2 differents threads

    * one in the CacheLineTable #put or CacheLineTable#remove
    * another in the CacheLineTable#get

this leads to the corruption of the LRUMap which is not thread-safe

the CacheLineTable#get should be synchronized or the LRUMap should be replaced by a thead safe collection

Modified:
    ofbiz/trunk/framework/base/src/org/ofbiz/base/util/cache/CacheLineTable.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=882072&r1=882071&r2=882072&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 Thu Nov 19 08:25:48 2009
@@ -140,7 +140,7 @@
         return oldValue;
     }
 
-    public CacheLine<V> get(Object key) {
+    public synchronized CacheLine<V> get(Object key) {
         if (key == null) {
             if (Debug.verboseOn()) Debug.logVerbose("In CacheLineTable tried to get with null key, using NullObject" + this.cacheName, module);
         }