jmeter-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From pmoua...@apache.org
Subject svn commit: r1208825 - /jmeter/trunk/src/core/org/apache/jmeter/gui/action/ActionRouter.java
Date Wed, 30 Nov 2011 22:02:41 GMT
Author: pmouawad
Date: Wed Nov 30 22:02:40 2011
New Revision: 1208825

URL: http://svn.apache.org/viewvc?rev=1208825&view=rev
Log:
Fixed potential double init if method is called concurrently

Modified:
    jmeter/trunk/src/core/org/apache/jmeter/gui/action/ActionRouter.java

Modified: jmeter/trunk/src/core/org/apache/jmeter/gui/action/ActionRouter.java
URL: http://svn.apache.org/viewvc/jmeter/trunk/src/core/org/apache/jmeter/gui/action/ActionRouter.java?rev=1208825&r1=1208824&r2=1208825&view=diff
==============================================================================
--- jmeter/trunk/src/core/org/apache/jmeter/gui/action/ActionRouter.java (original)
+++ jmeter/trunk/src/core/org/apache/jmeter/gui/action/ActionRouter.java Wed Nov 30 22:02:40
2011
@@ -41,6 +41,8 @@ import org.apache.log.Logger;
 public final class ActionRouter implements ActionListener {
     private static final Logger log = LoggingManager.getLoggerForClass();
 
+	private static final Object LOCK = new Object();
+
     private static ActionRouter router;
 
     private Map<String, Set<Command>> commands = new HashMap<String, Set<Command>>();
@@ -279,8 +281,12 @@ public final class ActionRouter implemen
      */
     public static ActionRouter getInstance() {
         if (router == null) {
-            router = new ActionRouter();
-            router.populateCommandMap();
+        	synchronized (LOCK) {
+        		if(router == null) {
+	                router = new ActionRouter();
+	                router.populateCommandMap();
+        		}				
+			}
         }
         return router;
     }



Mime
View raw message