Author: jonesde
Date: Mon Mar 9 08:30:14 2009 New Revision: 751619 URL: http://svn.apache.org/viewvc?rev=751619&view=rev Log: Changed the LRUMap inside CacheLineTable to be synchronized using Collections.synchronizedMap, should resolve issues reported in Jira #OFBIZ-2186 Modified: ofbiz/trunk/framework/base/src/org/ofbiz/base/util/cache/CacheLineTable.java ofbiz/trunk/framework/base/src/org/ofbiz/base/util/collections/LRUMap.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=751619&r1=751618&r2=751619&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 Mon Mar 9 08:30:14 2009 @@ -118,12 +118,12 @@ CacheLine<V> oldValue; if (key == null) { if (Debug.verboseOn()) Debug.logVerbose("In CacheLineTable tried to put with null key, using NullObject" + this.cacheName, module); - if (memoryTable instanceof LRUMap) { - oldValue = memoryTable.put(key, value); - } else { + if (memoryTable instanceof FastMap) { oldValue = isNullSet ? nullValue : null; isNullSet = true; nullValue = value; + } else { + oldValue = memoryTable.put(key, value); } } else { oldValue = memoryTable.put(key, value); @@ -149,14 +149,14 @@ protected CacheLine<V> getNoCheck(Object key) { CacheLine<V> value; - if (memoryTable instanceof LRUMap) { - value = memoryTable.get(key); - } else { + if (memoryTable instanceof FastMap) { if (key == null) { value = isNullSet ? nullValue : null; } else { value = memoryTable.get(key); } + } else { + value = memoryTable.get(key); } if (value == null) { if (fileTable != null) { @@ -183,11 +183,11 @@ } } if (key == null) { - if (memoryTable instanceof LRUMap) { - memoryTable.remove(key); - } else { + if (memoryTable instanceof FastMap) { isNullSet = false; nullValue = null; + } else { + memoryTable.remove(key); } } else { memoryTable.remove(key); @@ -279,7 +279,7 @@ } if (newSize > 0) { - this.memoryTable = new LRUMap<K, CacheLine<V>>(newSize); + this.memoryTable = Collections.synchronizedMap(new LRUMap<K, CacheLine<V>>(newSize)); if (isNullSet) { this.memoryTable.put(null, nullValue); isNullSet = false; @@ -311,4 +311,3 @@ return null; } } - Modified: ofbiz/trunk/framework/base/src/org/ofbiz/base/util/collections/LRUMap.java URL: http://svn.apache.org/viewvc/ofbiz/trunk/framework/base/src/org/ofbiz/base/util/collections/LRUMap.java?rev=751619&r1=751618&r2=751619&view=diff ============================================================================== --- ofbiz/trunk/framework/base/src/org/ofbiz/base/util/collections/LRUMap.java (original) +++ ofbiz/trunk/framework/base/src/org/ofbiz/base/util/collections/LRUMap.java Mon Mar 9 08:30:14 2009 @@ -57,13 +57,4 @@ protected boolean removeEldestEntry(Map.Entry<K, V> entry) { return size() > maxSize; } - - /** - * An override for the LinkedHashMap.get method that is synchronized to be thread safe. - * The LinkedHashMap.get method is not synchronized, as made very clear in the JavaDocs, and since it does modify internal state and in this case needs to be usable by more than one thread at once, making it synchronized. - */ - @Override - public synchronized V get(Object key) { - return super.get(key); - } } |
Free forum by Nabble | Edit this page |