ws-axis-cvs mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From d...@apache.org
Subject svn commit: r631403 - in /webservices/axis2/trunk/java/modules: integration/test/org/apache/axis2/engine/ kernel/src/org/apache/axis2/client/ kernel/src/org/apache/axis2/context/ kernel/src/org/apache/axis2/description/ kernel/src/org/apache/axis2/engi...
Date Tue, 26 Feb 2008 22:04:02 GMT
Author: dims
Date: Tue Feb 26 14:03:54 2008
New Revision: 631403

URL: http://svn.apache.org/viewvc?rev=631403&view=rev
Log:
Fix for AXIS2-1053 - ConcurrentModificationException when concurrent threads try to engage
the Addressing module

Modified:
    webservices/axis2/trunk/java/modules/integration/test/org/apache/axis2/engine/PausingHandlerExecutionTest.java
    webservices/axis2/trunk/java/modules/kernel/src/org/apache/axis2/client/ServiceClient.java
    webservices/axis2/trunk/java/modules/kernel/src/org/apache/axis2/context/MessageContext.java
    webservices/axis2/trunk/java/modules/kernel/src/org/apache/axis2/description/AxisDescription.java
    webservices/axis2/trunk/java/modules/kernel/src/org/apache/axis2/engine/Phase.java
    webservices/axis2/trunk/java/modules/kernel/test/org/apache/axis2/engine/MessageContextSaveATest.java
    webservices/axis2/trunk/java/modules/kernel/test/org/apache/axis2/engine/MessageContextSelfManagedDataTest.java
    webservices/axis2/trunk/java/modules/kernel/test/org/apache/axis2/phaserule/AddingHandlerToEachPhaseTest.java
    webservices/axis2/trunk/java/modules/kernel/test/org/apache/axis2/phaserule/PhaseRuleTests.java

Modified: webservices/axis2/trunk/java/modules/integration/test/org/apache/axis2/engine/PausingHandlerExecutionTest.java
URL: http://svn.apache.org/viewvc/webservices/axis2/trunk/java/modules/integration/test/org/apache/axis2/engine/PausingHandlerExecutionTest.java?rev=631403&r1=631402&r2=631403&view=diff
==============================================================================
--- webservices/axis2/trunk/java/modules/integration/test/org/apache/axis2/engine/PausingHandlerExecutionTest.java
(original)
+++ webservices/axis2/trunk/java/modules/integration/test/org/apache/axis2/engine/PausingHandlerExecutionTest.java
Tue Feb 26 14:03:54 2008
@@ -349,7 +349,7 @@
                     Phase phase = (Phase)handler;
                     System.out.println("Phase name [" + phase.getName() + "]");
 
-                    ArrayList list2 = phase.getHandlers();
+                    List list2 = phase.getHandlers();
                     Iterator it2 = list2.iterator();
                     checkHandler(it2);
                 }

Modified: webservices/axis2/trunk/java/modules/kernel/src/org/apache/axis2/client/ServiceClient.java
URL: http://svn.apache.org/viewvc/webservices/axis2/trunk/java/modules/kernel/src/org/apache/axis2/client/ServiceClient.java?rev=631403&r1=631402&r2=631403&view=diff
==============================================================================
--- webservices/axis2/trunk/java/modules/kernel/src/org/apache/axis2/client/ServiceClient.java
(original)
+++ webservices/axis2/trunk/java/modules/kernel/src/org/apache/axis2/client/ServiceClient.java
Tue Feb 26 14:03:54 2008
@@ -264,7 +264,9 @@
      * Returns the AxisConfiguration associated with the client.    
      */
     public AxisConfiguration getAxisConfiguration() {
-        return axisConfig;
+        synchronized(this.axisConfig) {
+            return axisConfig;
+        }
     }
     
     /**
@@ -336,7 +338,7 @@
      * @throws AxisFault if something goes wrong
      */
     public void engageModule(String moduleName) throws AxisFault {
-        synchronized (this) {
+        synchronized (this.axisConfig) {
             AxisModule module = axisConfig.getModule(moduleName);
             if (module != null) {
                 axisService.engageModule(module);
@@ -362,12 +364,14 @@
      * @param moduleName name of Module to disengage
      */
     public void disengageModule(String moduleName) {
-        AxisModule module = axisConfig.getModule(moduleName);
-        if (module != null) {
-            try {
-                axisService.disengageModule(module);
-            } catch (AxisFault axisFault) {
-                log.error(axisFault.getMessage(), axisFault);
+        synchronized (this.axisConfig) {
+            AxisModule module = axisConfig.getModule(moduleName);
+            if (module != null) {
+                try {
+                    axisService.disengageModule(module);
+                } catch (AxisFault axisFault) {
+                    log.error(axisFault.getMessage(), axisFault);
+                }
             }
         }
     }
@@ -536,10 +540,8 @@
         if(options.isCallTransportCleanup()){
             response.getEnvelope().build();
             cleanupTransport();
-            return response.getEnvelope().getBody().getFirstElement();
-        } else {
-            return response.getEnvelope().getBody().getFirstElement();
         }
+        return response.getEnvelope().getBody().getFirstElement();
     }
 
     /**
@@ -822,12 +824,13 @@
             throw new IllegalArgumentException("AxisService is null");
         }
 
-        axisConfig.removeService(this.axisService.getName());
-        this.axisService = axisService;
-
-        axisService.setClientSide(true);
-        axisConfig.addService(axisService);
-
+        synchronized(this.axisConfig) {
+            axisConfig.removeService(this.axisService.getName());
+            this.axisService = axisService;
+    
+            axisService.setClientSide(true);
+            axisConfig.addService(axisService);
+        }
         AxisServiceGroup axisServiceGroup = axisService.getAxisServiceGroup();
         ServiceGroupContext serviceGroupContext =
                 configContext.createServiceGroupContext(axisServiceGroup);

Modified: webservices/axis2/trunk/java/modules/kernel/src/org/apache/axis2/context/MessageContext.java
URL: http://svn.apache.org/viewvc/webservices/axis2/trunk/java/modules/kernel/src/org/apache/axis2/context/MessageContext.java?rev=631403&r1=631402&r2=631403&view=diff
==============================================================================
--- webservices/axis2/trunk/java/modules/kernel/src/org/apache/axis2/context/MessageContext.java
(original)
+++ webservices/axis2/trunk/java/modules/kernel/src/org/apache/axis2/context/MessageContext.java
Tue Feb 26 14:03:54 2008
@@ -74,6 +74,7 @@
 import java.util.LinkedHashMap;
 import java.util.LinkedList;
 import java.util.Map;
+import java.util.List;
 
 /**
  * <p>Axis2 states are held in two information models, called description hierarchy
@@ -1827,7 +1828,7 @@
      * @param map  users should pass null as this is just a holder for the recursion
      * @return a list of unigue object instances
      */
-    private ArrayList flattenHandlerList(ArrayList list, LinkedHashMap map) {
+    private ArrayList flattenHandlerList(List list, LinkedHashMap map) {
 
         if (map == null) {
             map = new LinkedHashMap();
@@ -3768,7 +3769,7 @@
      */
     private void setupPhaseList(Phase phase, MetaDataEntry mdPhase) {
         // get the list from the phase object
-        ArrayList handlers = phase.getHandlers();
+        List handlers = phase.getHandlers();
 
         if (handlers.isEmpty()) {
             // done, make sure there is no list in the given meta data

Modified: webservices/axis2/trunk/java/modules/kernel/src/org/apache/axis2/description/AxisDescription.java
URL: http://svn.apache.org/viewvc/webservices/axis2/trunk/java/modules/kernel/src/org/apache/axis2/description/AxisDescription.java?rev=631403&r1=631402&r2=631403&view=diff
==============================================================================
--- webservices/axis2/trunk/java/modules/kernel/src/org/apache/axis2/description/AxisDescription.java
(original)
+++ webservices/axis2/trunk/java/modules/kernel/src/org/apache/axis2/description/AxisDescription.java
Tue Feb 26 14:03:54 2008
@@ -16,6 +16,7 @@
 
 package org.apache.axis2.description;
 
+import edu.emory.mathcs.backport.java.util.concurrent.ConcurrentHashMap;
 import org.apache.axiom.om.OMAbstractFactory;
 import org.apache.axiom.om.OMElement;
 import org.apache.axiom.om.OMFactory;
@@ -36,7 +37,6 @@
 import java.io.StringWriter;
 import java.util.ArrayList;
 import java.util.Collection;
-import java.util.HashMap;
 import java.util.Iterator;
 import java.util.List;
 import java.util.Map;
@@ -50,7 +50,7 @@
 
     private PolicyInclude policyInclude = null;
 
-    private HashMap children;
+    private Map children;
 
     protected Map engagedModules;
 
@@ -67,7 +67,7 @@
 
     public AxisDescription() {
         parameterInclude = new ParameterIncludeImpl();
-        children = new HashMap();
+        children = new ConcurrentHashMap();
     }
 
     public void addParameterObserver(ParameterObserver observer) {
@@ -486,7 +486,7 @@
      * @throws AxisFault if there's a problem engaging
      */
     public void engageModule(AxisModule axisModule, AxisDescription source) throws AxisFault
{
-        if (engagedModules == null) engagedModules = new HashMap();
+        if (engagedModules == null) engagedModules = new ConcurrentHashMap();
         String moduleName = axisModule.getName();
         for (Iterator iterator = engagedModules.values().iterator(); iterator.hasNext();)
{
             AxisModule tempAxisModule = ((AxisModule) iterator.next());

Modified: webservices/axis2/trunk/java/modules/kernel/src/org/apache/axis2/engine/Phase.java
URL: http://svn.apache.org/viewvc/webservices/axis2/trunk/java/modules/kernel/src/org/apache/axis2/engine/Phase.java?rev=631403&r1=631402&r2=631403&view=diff
==============================================================================
--- webservices/axis2/trunk/java/modules/kernel/src/org/apache/axis2/engine/Phase.java (original)
+++ webservices/axis2/trunk/java/modules/kernel/src/org/apache/axis2/engine/Phase.java Tue
Feb 26 14:03:54 2008
@@ -20,6 +20,7 @@
 
 package org.apache.axis2.engine;
 
+import edu.emory.mathcs.backport.java.util.concurrent.CopyOnWriteArrayList;
 import org.apache.axis2.AxisFault;
 import org.apache.axis2.context.MessageContext;
 import org.apache.axis2.description.HandlerDescription;
@@ -30,8 +31,8 @@
 import org.apache.commons.logging.Log;
 import org.apache.commons.logging.LogFactory;
 
-import java.util.ArrayList;
 import java.util.Iterator;
+import java.util.List;
 
 /**
  * A Phase is an ordered collection of Handlers.
@@ -48,7 +49,7 @@
     /**
      * Field handlers
      */
-    private ArrayList handlers;
+    private List handlers;
 
     /**
      * A handler has been marked as present in both the first phase and the last phase
@@ -83,7 +84,7 @@
      * @param phaseName the name for this Phase
      */
     public Phase(String phaseName) {
-        handlers = new ArrayList();
+        handlers = new CopyOnWriteArrayList();
         this.phaseName = phaseName;
     }
 
@@ -113,7 +114,7 @@
      * @param handlerDesc the HandlerDescription to add
      * @throws PhaseException if there is a problem
      */
-    public synchronized void addHandler(HandlerDescription handlerDesc) throws PhaseException
{
+    public void addHandler(HandlerDescription handlerDesc) throws PhaseException {
         Iterator handlers_itr = getHandlers().iterator();
 
         while (handlers_itr.hasNext()) {
@@ -131,7 +132,7 @@
         }
 
         if (handlerDesc.getRules().isPhaseFirst() && handlerDesc.getRules().isPhaseLast())
{
-            if (handlers.size() > 0) {
+            if (!handlers.isEmpty()) {
                 throw new PhaseException(this.getPhaseName()
                         + " already contains Handlers, and "
                         + handlerDesc.getName()
@@ -356,7 +357,7 @@
      *
      * @return Returns an ArrayList of Handlers
      */
-    public ArrayList getHandlers() {
+    public List getHandlers() {
         return handlers;
     }
 

Modified: webservices/axis2/trunk/java/modules/kernel/test/org/apache/axis2/engine/MessageContextSaveATest.java
URL: http://svn.apache.org/viewvc/webservices/axis2/trunk/java/modules/kernel/test/org/apache/axis2/engine/MessageContextSaveATest.java?rev=631403&r1=631402&r2=631403&view=diff
==============================================================================
--- webservices/axis2/trunk/java/modules/kernel/test/org/apache/axis2/engine/MessageContextSaveATest.java
(original)
+++ webservices/axis2/trunk/java/modules/kernel/test/org/apache/axis2/engine/MessageContextSaveATest.java
Tue Feb 26 14:03:54 2008
@@ -61,6 +61,7 @@
 import java.util.ArrayList;
 import java.util.HashMap;
 import java.util.Iterator;
+import java.util.List;
 
 import junit.framework.TestCase;
 
@@ -494,8 +495,8 @@
                 String name1 = p1.getName();
                 String name2 = p2.getName();
 
-                ArrayList list1 = p1.getHandlers();
-                ArrayList list2 = p2.getHandlers();
+                List list1 = p1.getHandlers();
+                List list2 = p2.getHandlers();
 
                 if ((list1 == null) && (list2 == null)) {
                     log.debug("MessageContextSaveATest: comparePhases:  Phase1[" + name1
+

Modified: webservices/axis2/trunk/java/modules/kernel/test/org/apache/axis2/engine/MessageContextSelfManagedDataTest.java
URL: http://svn.apache.org/viewvc/webservices/axis2/trunk/java/modules/kernel/test/org/apache/axis2/engine/MessageContextSelfManagedDataTest.java?rev=631403&r1=631402&r2=631403&view=diff
==============================================================================
--- webservices/axis2/trunk/java/modules/kernel/test/org/apache/axis2/engine/MessageContextSelfManagedDataTest.java
(original)
+++ webservices/axis2/trunk/java/modules/kernel/test/org/apache/axis2/engine/MessageContextSelfManagedDataTest.java
Tue Feb 26 14:03:54 2008
@@ -60,6 +60,7 @@
 import java.io.ObjectOutputStream;
 import java.util.ArrayList;
 import java.util.Iterator;
+import java.util.List;
 
 public class MessageContextSelfManagedDataTest extends TestCase {
     protected static final Log log = LogFactory.getLog(MessageContextSelfManagedDataTest.class);
@@ -913,8 +914,8 @@
                 Phase p1 = (Phase) o1;
                 Phase p2 = (Phase) o2;
 
-                ArrayList list1 = p1.getHandlers();
-                ArrayList list2 = p2.getHandlers();
+                List list1 = p1.getHandlers();
+                List list2 = p2.getHandlers();
 
                 if ((list1 == null) && (list2 == null)) {
                     return true;

Modified: webservices/axis2/trunk/java/modules/kernel/test/org/apache/axis2/phaserule/AddingHandlerToEachPhaseTest.java
URL: http://svn.apache.org/viewvc/webservices/axis2/trunk/java/modules/kernel/test/org/apache/axis2/phaserule/AddingHandlerToEachPhaseTest.java?rev=631403&r1=631402&r2=631403&view=diff
==============================================================================
--- webservices/axis2/trunk/java/modules/kernel/test/org/apache/axis2/phaserule/AddingHandlerToEachPhaseTest.java
(original)
+++ webservices/axis2/trunk/java/modules/kernel/test/org/apache/axis2/phaserule/AddingHandlerToEachPhaseTest.java
Tue Feb 26 14:03:54 2008
@@ -27,6 +27,7 @@
 import org.apache.axis2.phaseresolver.PhaseHolder;
 
 import java.util.ArrayList;
+import java.util.List;
 
 public class AddingHandlerToEachPhaseTest extends AbstractTestCase {
     AxisConfiguration axisConfig;
@@ -60,9 +61,9 @@
         for (int i = 0; i < inPhase.size(); i++) {
             found = false;
             Phase phase = (Phase) inPhase.get(i);
-            ArrayList hnadles = phase.getHandlers();
-            for (int j = 0; j < hnadles.size(); j++) {
-                Handler handler = (Handler) hnadles.get(j);
+            List handlers = phase.getHandlers();
+            for (int j = 0; j < handlers.size(); j++) {
+                Handler handler = (Handler) handlers.get(j);
                 if (h1.equals(handler)) {
                     found = true;
                 }
@@ -99,8 +100,8 @@
         ph.addHandler(hm);
         for (int i = 0; i < inPhase.size(); i++) {
             Phase phase = (Phase) inPhase.get(i);
-            ArrayList hnadles = phase.getHandlers();
-            Handler handler = (Handler) hnadles.get(0);
+            List handlers = phase.getHandlers();
+            Handler handler = (Handler) handlers.get(0);
             if (!h1.equals(handler)) {
                 fail("Some thing has gone wrong hnadler does not exit as phase " +
                         "first handler the phase :"
@@ -133,8 +134,8 @@
         ph.addHandler(hm);
         for (int i = 0; i < inPhase.size(); i++) {
             Phase phase = (Phase) inPhase.get(i);
-            ArrayList hnadles = phase.getHandlers();
-            Handler handler = (Handler) hnadles.get(0);
+            List handlers = phase.getHandlers();
+            Handler handler = (Handler) handlers.get(0);
             assertNull(handler.getHandlerDesc().getRules().getAfter());
         }
     }

Modified: webservices/axis2/trunk/java/modules/kernel/test/org/apache/axis2/phaserule/PhaseRuleTests.java
URL: http://svn.apache.org/viewvc/webservices/axis2/trunk/java/modules/kernel/test/org/apache/axis2/phaserule/PhaseRuleTests.java?rev=631403&r1=631402&r2=631403&view=diff
==============================================================================
--- webservices/axis2/trunk/java/modules/kernel/test/org/apache/axis2/phaserule/PhaseRuleTests.java
(original)
+++ webservices/axis2/trunk/java/modules/kernel/test/org/apache/axis2/phaserule/PhaseRuleTests.java
Tue Feb 26 14:03:54 2008
@@ -32,6 +32,7 @@
 
 import java.util.ArrayList;
 import java.util.Iterator;
+import java.util.List;
 
 import junit.framework.TestCase;
 
@@ -79,7 +80,7 @@
         hm1.setRules(rule1);
         ph.addHandler(hm1);
 
-        ArrayList handlers = p1.getHandlers();
+        List handlers = p1.getHandlers();
         Handler handler = (Handler) handlers.get(0);
         if (handler != h2) {
             fail("Computed Hnadler order is wrong ");
@@ -128,7 +129,7 @@
         hm.setRules(rule);
         ph.addHandler(hm);
 
-        ArrayList handlers = p1.getHandlers();
+        List handlers = p1.getHandlers();
         Handler handler = (Handler) handlers.get(0);
         if (handler != h2) {
             fail("Computed Handler order is wrong ");
@@ -200,7 +201,7 @@
         hm4.setRules(rule4);
         ph.addHandler(hm4);
 
-        ArrayList handlers = p1.getHandlers();
+        List handlers = p1.getHandlers();
         boolean foundH1 = false;
         boolean foundH4 = false;
 



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


Mime
View raw message