[gatein-commits] gatein SVN: r5445 - in portal/branches/branch-GTNPORTAL-1700/webui: portal/src/test/java/org/exoplatform/portal/webui/test and 1 other directory.

do-not-reply at jboss.org do-not-reply at jboss.org
Thu Dec 2 03:10:34 EST 2010


Author: hoang_to
Date: 2010-12-02 03:10:33 -0500 (Thu, 02 Dec 2010)
New Revision: 5445

Modified:
   portal/branches/branch-GTNPORTAL-1700/webui/framework/src/main/java/org/exoplatform/webui/config/Component.java
   portal/branches/branch-GTNPORTAL-1700/webui/portal/src/test/java/org/exoplatform/portal/webui/test/ComponentConfigConcurrentTest.java
Log:
GTNPORTAL-1541: Add volatile specifier on eventMap to make double-checked pattern work properly

Modified: portal/branches/branch-GTNPORTAL-1700/webui/framework/src/main/java/org/exoplatform/webui/config/Component.java
===================================================================
--- portal/branches/branch-GTNPORTAL-1700/webui/framework/src/main/java/org/exoplatform/webui/config/Component.java	2010-12-02 08:10:03 UTC (rev 5444)
+++ portal/branches/branch-GTNPORTAL-1700/webui/framework/src/main/java/org/exoplatform/webui/config/Component.java	2010-12-02 08:10:33 UTC (rev 5445)
@@ -56,7 +56,8 @@
 
    private final List<EventInterceptor> eventInterceptors;
 
-   private Map<String, Event> eventMap;
+   /** Declare this map as volatile to make double-check work properly **/
+   private volatile Map<String, Event> eventMap;
 
    private Lifecycle<UIComponent> componentLifecycle;
 
@@ -182,18 +183,21 @@
          {
             if(eventMap == null)
             {
-               eventMap = new HashMap<String, Event>();
+               Map<String, Event> temporaryMap = new HashMap<String, Event>();
 
                if (events == null)
                {
+                  eventMap = temporaryMap;
                   return null;
                }
 
                for (Event event : events)
                {
                   createCachedEventListeners(event);
-                  eventMap.put(event.getName(), event);
+                  temporaryMap.put(event.getName(), event);
                }
+               
+               eventMap = temporaryMap;
             }
             
             return eventMap.get(eventName);

Modified: portal/branches/branch-GTNPORTAL-1700/webui/portal/src/test/java/org/exoplatform/portal/webui/test/ComponentConfigConcurrentTest.java
===================================================================
--- portal/branches/branch-GTNPORTAL-1700/webui/portal/src/test/java/org/exoplatform/portal/webui/test/ComponentConfigConcurrentTest.java	2010-12-02 08:10:03 UTC (rev 5444)
+++ portal/branches/branch-GTNPORTAL-1700/webui/portal/src/test/java/org/exoplatform/portal/webui/test/ComponentConfigConcurrentTest.java	2010-12-02 08:10:33 UTC (rev 5445)
@@ -43,7 +43,7 @@
  */
 public class ComponentConfigConcurrentTest extends AbstractGateInTest 
 {
-	private static final int WORKERS_COUNT = 20;
+	private static final int WORKERS_COUNT = 50;
 	
 	private MockApplication mockApplication;
 	
@@ -80,10 +80,9 @@
 		}
 		
 		// Go throguh all workers and throw error if some worker has null eventConfig
-		// Minh Hoang TO: Comment the assertNotNull as the test result is non-determinist for the moment
 		for (Worker worker : workers)
 		{
-			//assertNotNull("event configuration is null in worker " + worker.getName(), worker.eventConfig);
+			assertNotNull("event configuration is null in worker " + worker.getName(), worker.eventConfig);
 		}		
 
 		// destroy mock application



More information about the gatein-commits mailing list