You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@cxf.apache.org by dk...@apache.org on 2014/06/04 16:12:50 UTC

git commit: More race conditions fixes

Repository: cxf
Updated Branches:
  refs/heads/master b7ad1f3c5 -> 037da2d96


More race conditions fixes


Project: http://git-wip-us.apache.org/repos/asf/cxf/repo
Commit: http://git-wip-us.apache.org/repos/asf/cxf/commit/037da2d9
Tree: http://git-wip-us.apache.org/repos/asf/cxf/tree/037da2d9
Diff: http://git-wip-us.apache.org/repos/asf/cxf/diff/037da2d9

Branch: refs/heads/master
Commit: 037da2d9693ff7de7fd85b9d1fc85550831a2133
Parents: b7ad1f3
Author: Daniel Kulp <dk...@apache.org>
Authored: Wed Jun 4 10:12:35 2014 -0400
Committer: Daniel Kulp <dk...@apache.org>
Committed: Wed Jun 4 10:12:35 2014 -0400

----------------------------------------------------------------------
 .../cxf/ws/policy/EndpointPolicyImpl.java       | 41 ++++++++++++--------
 1 file changed, 24 insertions(+), 17 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cxf/blob/037da2d9/rt/ws/policy/src/main/java/org/apache/cxf/ws/policy/EndpointPolicyImpl.java
----------------------------------------------------------------------
diff --git a/rt/ws/policy/src/main/java/org/apache/cxf/ws/policy/EndpointPolicyImpl.java b/rt/ws/policy/src/main/java/org/apache/cxf/ws/policy/EndpointPolicyImpl.java
index 3df3c3b..2cc8341 100644
--- a/rt/ws/policy/src/main/java/org/apache/cxf/ws/policy/EndpointPolicyImpl.java
+++ b/rt/ws/policy/src/main/java/org/apache/cxf/ws/policy/EndpointPolicyImpl.java
@@ -50,9 +50,9 @@ public class EndpointPolicyImpl implements EndpointPolicy {
     private Policy policy;
     private Collection<Assertion> chosenAlternative;
     
-    private Collection<Assertion> vocabulary;
+    private volatile Collection<Assertion> vocabulary;
     private Collection<Assertion> faultVocabulary;
-    private List<Interceptor<? extends Message>> interceptors;
+    private volatile List<Interceptor<? extends Message>> interceptors;
     private List<Interceptor<? extends Message>> faultInterceptors;
     
     private EndpointInfo ei;
@@ -194,9 +194,10 @@ public class EndpointPolicyImpl implements EndpointPolicy {
             return;
         }
 
-        vocabulary = new ArrayList<Assertion>();
+        List<Assertion> v = new ArrayList<Assertion>();
+        List<Assertion> fv = null;
         if (requestor) {
-            faultVocabulary = new ArrayList<Assertion>();
+            fv = new ArrayList<Assertion>();
         }
        
         // vocabulary of alternative chosen for endpoint
@@ -205,9 +206,9 @@ public class EndpointPolicyImpl implements EndpointPolicy {
                 if (a.isOptional()) {
                     continue;
                 }
-                vocabulary.add(a);            
-                if (null != faultVocabulary) {
-                    faultVocabulary.add(a);
+                v.add(a);            
+                if (null != fv) {
+                    fv.add(a);
                 }
             }
         }
@@ -220,28 +221,32 @@ public class EndpointPolicyImpl implements EndpointPolicy {
                 p = engine.getEffectiveServerRequestPolicy(ei, boi, m);
                 Collection<Assertion> c = engine.getAssertions(p, false);
                 if (c != null) {
-                    addAll(vocabulary, c);
+                    addAll(v, c);
                 }
             } else {
                 p = engine.getEffectiveClientResponsePolicy(ei, boi, m);
                 Collection<Assertion> c = engine.getAssertions(p, false);
                 if (c != null) {
-                    addAll(vocabulary, c);
-                    if (null != faultVocabulary) {
-                        addAll(faultVocabulary, c);
+                    addAll(v, c);
+                    if (null != fv) {
+                        addAll(fv, c);
                     }
                 }
-                if (boi.getFaults() != null && null != faultVocabulary) {
+                if (boi.getFaults() != null && null != fv) {
                     for (BindingFaultInfo bfi : boi.getFaults()) {
                         p = engine.getEffectiveClientFaultPolicy(ei, boi, bfi, m);
                         c = engine.getAssertions(p, false);
                         if (c != null) {
-                            addAll(faultVocabulary, c);
+                            addAll(fv, c);
                         }
                     }
                 }
             }
         }
+        if (requestor) {
+            faultVocabulary = fv;
+        }
+        vocabulary = v;
     }
 
     Collection<Assertion> getSupportedAlternatives(Policy p, Message msg) {
@@ -292,11 +297,12 @@ public class EndpointPolicyImpl implements EndpointPolicy {
             }
         }
 
+        List<Interceptor<? extends Message>> tmp = null;
         if (requestor) {
-            interceptors = new ArrayList<Interceptor<? extends Message>>(out);
+            tmp = new ArrayList<Interceptor<? extends Message>>(out);
             out.clear();
             for (Assertion a : getChosenAlternative()) {
-                initializeInterceptors(reg, out, a, true, m);
+                initializeInterceptors(reg, out, a, true, m);                
             }
             faultInterceptors = new ArrayList<Interceptor<? extends Message>>(out);
         } else if (ei != null && ei.getBinding() != null) {
@@ -313,10 +319,11 @@ public class EndpointPolicyImpl implements EndpointPolicy {
                     }
                 }
             }
-            interceptors = new ArrayList<Interceptor<? extends Message>>(out);
+            tmp = new ArrayList<Interceptor<? extends Message>>(out);
         } else {
-            interceptors = new ArrayList<Interceptor<? extends Message>>(out);            
+            tmp = new ArrayList<Interceptor<? extends Message>>(out);            
         }
+        interceptors = tmp;
     }
     
     // for test