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

svn commit: r744205 - in /ofbiz/trunk/framework/base/src/org/ofbiz/base/util: cache/CacheLineTable.java cache/UtilCache.java collections/LRUMap.java

Author: jonesde
Date: Fri Feb 13 18:25:50 2009
New Revision: 744205

URL: http://svn.apache.org/viewvc?rev=744205&view=rev
Log:
Changed LRUMap.get to be synchronized to hopefully resolve issue reported by Philippe Mouawad in Jira #OFBIZ-2186; comments in code discuss why this is needed; get is ONLY synchronized for the LRUMap, and not for caches where there is no size limit

Modified:
    ofbiz/trunk/framework/base/src/org/ofbiz/base/util/cache/CacheLineTable.java
    ofbiz/trunk/framework/base/src/org/ofbiz/base/util/cache/UtilCache.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=744205&r1=744204&r2=744205&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 Fri Feb 13 18:25:50 2009
@@ -35,7 +35,7 @@
 import org.ofbiz.base.util.UtilValidate;
 import org.ofbiz.base.util.collections.LRUMap;
 
-
+@SuppressWarnings("serial")
 public class CacheLineTable<K, V> implements Serializable {
 
     public static final String module = CacheLineTable.class.getName();

Modified: ofbiz/trunk/framework/base/src/org/ofbiz/base/util/cache/UtilCache.java
URL: http://svn.apache.org/viewvc/ofbiz/trunk/framework/base/src/org/ofbiz/base/util/cache/UtilCache.java?rev=744205&r1=744204&r2=744205&view=diff
==============================================================================
--- ofbiz/trunk/framework/base/src/org/ofbiz/base/util/cache/UtilCache.java (original)
+++ ofbiz/trunk/framework/base/src/org/ofbiz/base/util/cache/UtilCache.java Fri Feb 13 18:25:50 2009
@@ -20,7 +20,6 @@
 
 import java.io.Serializable;
 import java.util.Collection;
-import java.util.Iterator;
 import java.util.List;
 import java.util.Map;
 import java.util.MissingResourceException;
@@ -46,6 +45,7 @@
  * </ul>
  *
  */
+@SuppressWarnings("serial")
 public class UtilCache<K, V> implements Serializable {
 
     public static final String module = UtilCache.class.getName();

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=744205&r1=744204&r2=744205&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 Fri Feb 13 18:25:50 2009
@@ -25,6 +25,7 @@
  * LifoSet - Set interface wrapper around a LinkedList
  *
  */
+@SuppressWarnings("serial")
 public class LRUMap<K, V> extends LinkedHashMap<K, V> {
     private int maxSize;
 
@@ -57,4 +58,12 @@
         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);
+    }
 }