You are viewing a plain text version of this content. The canonical link for it is here.
Posted to java-dev@axis.apache.org by da...@apache.org on 2008/05/14 20:40:34 UTC

svn commit: r656353 - /webservices/axis2/trunk/java/modules/kernel/src/org/apache/axis2/addressing/EndpointReference.java

Author: davidillsley
Date: Wed May 14 11:40:34 2008
New Revision: 656353

URL: http://svn.apache.org/viewvc?rev=656353&view=rev
Log:
Avoid synchronization in EndpointReference.hasAnonymousAddress using the technique outlined at
http://www.ibm.com/developerworks/java/library/j-hashmap.html

Modified:
    webservices/axis2/trunk/java/modules/kernel/src/org/apache/axis2/addressing/EndpointReference.java

Modified: webservices/axis2/trunk/java/modules/kernel/src/org/apache/axis2/addressing/EndpointReference.java
URL: http://svn.apache.org/viewvc/webservices/axis2/trunk/java/modules/kernel/src/org/apache/axis2/addressing/EndpointReference.java?rev=656353&r1=656352&r2=656353&view=diff
==============================================================================
--- webservices/axis2/trunk/java/modules/kernel/src/org/apache/axis2/addressing/EndpointReference.java (original)
+++ webservices/axis2/trunk/java/modules/kernel/src/org/apache/axis2/addressing/EndpointReference.java Wed May 14 11:40:34 2008
@@ -78,7 +78,7 @@
      * The list of URIs that should be considered equivalent to 
      * the WS-Addressing anonymous URI
      */
-    private static List anonymousEquivalentURIs = new ArrayList();
+    private static volatile List anonymousEquivalentURIs = new ArrayList();
 
 
     /**
@@ -114,8 +114,12 @@
         if (log.isTraceEnabled())
         	log.trace("addAnonymousEquivalentURI: " + anonymousEquivalentURI);
         
+        // Avoid synchronization in hasAnonymousAddress by using the
+        // technique outlined at http://is.gd/gv3
         synchronized (anonymousEquivalentURIs) {
-            anonymousEquivalentURIs.add(anonymousEquivalentURI);
+        	ArrayList newList = new ArrayList(anonymousEquivalentURIs);
+        	newList.add(anonymousEquivalentURI);
+            anonymousEquivalentURIs = newList;
         }
     }
  
@@ -219,18 +223,19 @@
         boolean result = isWSAddressingAnonymous();
         
         if(!result && address != null) {
-        	//If the address is not WS-A anonymous it might still be considered anonymous
-        	synchronized(anonymousEquivalentURIs){
-        		if(!anonymousEquivalentURIs.isEmpty()){
-            		Iterator it = anonymousEquivalentURIs.iterator();
-            		while(it.hasNext()){
-            			result = address.startsWith((String)it.next());
-            			if(result){
-            				break;
-            			}
-            		}	
-        		}
-        	} //end sync      	
+        	// If the address is not WS-A anonymous it might still be considered anonymous
+        	// Avoid synchronization by using the
+            // technique outlined at http://is.gd/gv3
+        	List localList = anonymousEquivalentURIs;
+        	if(!localList.isEmpty()){
+        		Iterator it = localList.iterator();
+        		while(it.hasNext()){
+        			result = address.startsWith((String)it.next());
+        			if(result){
+        				break;
+        			}
+        		}	
+        	}    	
         }
 
         if (log.isTraceEnabled()) {



---------------------------------------------------------------------
To unsubscribe, e-mail: axis-cvs-unsubscribe@ws.apache.org
For additional commands, e-mail: axis-cvs-help@ws.apache.org