You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@ofbiz.apache.org by do...@apache.org on 2012/04/19 01:48:14 UTC

svn commit: r1327731 - /ofbiz/trunk/framework/service/src/org/ofbiz/service/ServiceDispatcher.java

Author: doogie
Date: Wed Apr 18 23:48:14 2012
New Revision: 1327731

URL: http://svn.apache.org/viewvc?rev=1327731&view=rev
Log:
FIX: No longer use LRUMap, but ConcurrentLinkedHashMap.  This fixes the
case where getSerivceLogMap is called, and the elements are enumerated.
This could cause an error when the calling code was enumerating the map,
to print out it's information, but a service that was represented in the
map would finish, and get removed from the map.  The calling code that
had the map might then get stuck in a loop that would never end(internal
to the map itself).

Modified:
    ofbiz/trunk/framework/service/src/org/ofbiz/service/ServiceDispatcher.java

Modified: ofbiz/trunk/framework/service/src/org/ofbiz/service/ServiceDispatcher.java
URL: http://svn.apache.org/viewvc/ofbiz/trunk/framework/service/src/org/ofbiz/service/ServiceDispatcher.java?rev=1327731&r1=1327730&r2=1327731&view=diff
==============================================================================
--- ofbiz/trunk/framework/service/src/org/ofbiz/service/ServiceDispatcher.java (original)
+++ ofbiz/trunk/framework/service/src/org/ofbiz/service/ServiceDispatcher.java Wed Apr 18 23:48:14 2012
@@ -34,7 +34,6 @@ import org.ofbiz.base.util.UtilPropertie
 import org.ofbiz.base.util.UtilTimer;
 import org.ofbiz.base.util.UtilValidate;
 import org.ofbiz.base.util.UtilXml;
-import org.ofbiz.base.util.collections.LRUMap;
 import org.ofbiz.entity.Delegator;
 import org.ofbiz.entity.DelegatorFactory;
 import org.ofbiz.entity.GenericDelegator;
@@ -60,6 +59,9 @@ import org.ofbiz.service.job.JobManagerE
 import org.ofbiz.service.semaphore.ServiceSemaphore;
 import org.w3c.dom.Element;
 
+import com.googlecode.concurrentlinkedhashmap.ConcurrentLinkedHashMap;
+import com.googlecode.concurrentlinkedhashmap.ConcurrentLinkedHashMap.Builder;
+
 /**
  * Global Service Dispatcher
  */
@@ -69,7 +71,7 @@ public class ServiceDispatcher {
     public static final int lruLogSize = 200;
     public static final int LOCK_RETRIES = 3;
 
-    protected static final Map<RunningService, ServiceDispatcher> runLog = new LRUMap<RunningService, ServiceDispatcher>(lruLogSize);
+    protected static final Map<RunningService, ServiceDispatcher> runLog = new ConcurrentLinkedHashMap.Builder<RunningService, ServiceDispatcher>().maximumWeightedCapacity(lruLogSize).build();
     protected static Map<String, ServiceDispatcher> dispatchers = FastMap.newInstance();
     protected static boolean enableJM = true;
     protected static boolean enableJMS = true;
@@ -1059,9 +1061,7 @@ public class ServiceDispatcher {
     private RunningService logService(String localName, ModelService modelService, int mode) {
         // set up the running service log
         RunningService rs = new RunningService(localName, modelService, mode);
-        synchronized(runLog) {
-            runLog.put(rs, this);
-        }
+        runLog.put(rs, this);
         return rs;
     }