cxf-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From dsosno...@apache.org
Subject svn commit: r1073249 - in /cxf/trunk/rt/ws/rm/src/main/java/org/apache/cxf/ws/rm: Destination.java RMInInterceptor.java RMProperties.java soap/RMSoapInterceptor.java
Date Tue, 22 Feb 2011 08:22:32 GMT
Author: dsosnoski
Date: Tue Feb 22 08:22:32 2011
New Revision: 1073249

URL: http://svn.apache.org/viewvc?rev=1073249&view=rev
Log:
Eliminate need for synchronization blocks by converting to CopyOnWriteArrayList collections.

Modified:
    cxf/trunk/rt/ws/rm/src/main/java/org/apache/cxf/ws/rm/Destination.java
    cxf/trunk/rt/ws/rm/src/main/java/org/apache/cxf/ws/rm/RMInInterceptor.java
    cxf/trunk/rt/ws/rm/src/main/java/org/apache/cxf/ws/rm/RMProperties.java
    cxf/trunk/rt/ws/rm/src/main/java/org/apache/cxf/ws/rm/soap/RMSoapInterceptor.java

Modified: cxf/trunk/rt/ws/rm/src/main/java/org/apache/cxf/ws/rm/Destination.java
URL: http://svn.apache.org/viewvc/cxf/trunk/rt/ws/rm/src/main/java/org/apache/cxf/ws/rm/Destination.java?rev=1073249&r1=1073248&r2=1073249&view=diff
==============================================================================
--- cxf/trunk/rt/ws/rm/src/main/java/org/apache/cxf/ws/rm/Destination.java (original)
+++ cxf/trunk/rt/ws/rm/src/main/java/org/apache/cxf/ws/rm/Destination.java Tue Feb 22 08:22:32
2011
@@ -140,14 +140,13 @@ public class Destination extends Abstrac
         if (null == ars) {
             return;
         }
-        synchronized (ars) {
-            for (AckRequestedType ar : ars) {
-                Identifier id = ar.getIdentifier();
-                DestinationSequence seq = getSequence(id);
-                if (null != seq) {
-                    ackImmediately(seq, message);
-                }
+        for (AckRequestedType ar : ars) {
+            Identifier id = ar.getIdentifier();
+            DestinationSequence seq = getSequence(id);
+            if (null == seq) {
+                continue;
             }
+            ackImmediately(seq, message);
         }
     }
     

Modified: cxf/trunk/rt/ws/rm/src/main/java/org/apache/cxf/ws/rm/RMInInterceptor.java
URL: http://svn.apache.org/viewvc/cxf/trunk/rt/ws/rm/src/main/java/org/apache/cxf/ws/rm/RMInInterceptor.java?rev=1073249&r1=1073248&r2=1073249&view=diff
==============================================================================
--- cxf/trunk/rt/ws/rm/src/main/java/org/apache/cxf/ws/rm/RMInInterceptor.java (original)
+++ cxf/trunk/rt/ws/rm/src/main/java/org/apache/cxf/ws/rm/RMInInterceptor.java Tue Feb 22
08:22:32 2011
@@ -123,15 +123,13 @@ public class RMInInterceptor extends Abs
         
         Collection<SequenceAcknowledgement> acks = rmps.getAcks();
         if (null != acks) {
-            synchronized (acks) {
-                for (SequenceAcknowledgement ack : acks) {
-                    Identifier id = ack.getIdentifier();
-                    SourceSequence ss = source.getSequence(id);                
-                    if (null != ss) {
-                        ss.setAcknowledged(ack);
-                    } else {
-                        throw (new SequenceFaultFactory()).createUnknownSequenceFault(id);
-                    }
+            for (SequenceAcknowledgement ack : acks) {
+                Identifier id = ack.getIdentifier();
+                SourceSequence ss = source.getSequence(id);                
+                if (null != ss) {
+                    ss.setAcknowledged(ack);
+                } else {
+                    throw (new SequenceFaultFactory()).createUnknownSequenceFault(id);
                 }
             }
         }

Modified: cxf/trunk/rt/ws/rm/src/main/java/org/apache/cxf/ws/rm/RMProperties.java
URL: http://svn.apache.org/viewvc/cxf/trunk/rt/ws/rm/src/main/java/org/apache/cxf/ws/rm/RMProperties.java?rev=1073249&r1=1073248&r2=1073249&view=diff
==============================================================================
--- cxf/trunk/rt/ws/rm/src/main/java/org/apache/cxf/ws/rm/RMProperties.java (original)
+++ cxf/trunk/rt/ws/rm/src/main/java/org/apache/cxf/ws/rm/RMProperties.java Tue Feb 22 08:22:32
2011
@@ -21,6 +21,7 @@ package org.apache.cxf.ws.rm;
 
 import java.util.ArrayList;
 import java.util.Collection;
+import java.util.concurrent.CopyOnWriteArrayList;
 
 public class RMProperties {
     private SequenceType sequence;
@@ -40,15 +41,13 @@ public class RMProperties {
     }
     
     public void setAcks(Collection<SequenceAcknowledgement> a) {
-        synchronized (a) {
-            acks = a;
-        }
+        // use threadsafe implementation for working copy, to avoid concurrent modifications
+        acks = new CopyOnWriteArrayList<SequenceAcknowledgement>(a);
     }
     
     public void setAcksRequested(Collection<AckRequestedType> ar) {
-        synchronized (ar) {
-            acksRequested = ar;
-        }
+        // use threadsafe implementation for working copy, to avoid concurrent modifications
+        acksRequested = new CopyOnWriteArrayList<AckRequestedType>(ar);       
     }
     
     public void setSequence(SequenceType s) {
@@ -69,11 +68,9 @@ public class RMProperties {
         if (null == acks) {
             acks = new ArrayList<SequenceAcknowledgement>();
         }
-        synchronized (acks) {
-            SequenceAcknowledgement ack = seq.getAcknowledgment();
-            acks.add(ack);
-            seq.acknowledgmentSent();
-        }
+        SequenceAcknowledgement ack = seq.getAcknowledgment();
+        acks.add(ack);
+        seq.acknowledgmentSent();
     }
   
 }

Modified: cxf/trunk/rt/ws/rm/src/main/java/org/apache/cxf/ws/rm/soap/RMSoapInterceptor.java
URL: http://svn.apache.org/viewvc/cxf/trunk/rt/ws/rm/src/main/java/org/apache/cxf/ws/rm/soap/RMSoapInterceptor.java?rev=1073249&r1=1073248&r2=1073249&view=diff
==============================================================================
--- cxf/trunk/rt/ws/rm/src/main/java/org/apache/cxf/ws/rm/soap/RMSoapInterceptor.java (original)
+++ cxf/trunk/rt/ws/rm/src/main/java/org/apache/cxf/ws/rm/soap/RMSoapInterceptor.java Tue
Feb 22 08:22:32 2011
@@ -202,26 +202,22 @@ public class RMSoapInterceptor extends A
             } 
             Collection<SequenceAcknowledgement> acks = rmps.getAcks();
             if (null != acks) {
-                synchronized (acks) {
-                    for (SequenceAcknowledgement ack : acks) {
-                        encodeProperty(ack, 
-                                       RMConstants.getSequenceAckQName(), 
-                                       SequenceAcknowledgement.class, 
-                                       hdr,
-                                       marshaller);
-                    }
+                for (SequenceAcknowledgement ack : acks) {
+                    encodeProperty(ack, 
+                                   RMConstants.getSequenceAckQName(), 
+                                   SequenceAcknowledgement.class, 
+                                   hdr,
+                                   marshaller);
                 }
             }
             Collection<AckRequestedType> requested = rmps.getAcksRequested();
             if (null != requested) {
-                synchronized (requested) {
-                    for (AckRequestedType ar : requested) {
-                        encodeProperty(ar, 
-                                       RMConstants.getAckRequestedQName(), 
-                                       AckRequestedType.class, 
-                                       hdr,
-                                       marshaller);
-                    }
+                for (AckRequestedType ar : requested) {
+                    encodeProperty(ar, 
+                                   RMConstants.getAckRequestedQName(), 
+                                   AckRequestedType.class, 
+                                   hdr,
+                                   marshaller);
                 }
             }
             Node node = hdr.getFirstChild();



Mime
View raw message