cxf-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From asold...@apache.org
Subject [1/3] cxf git commit: [CXF-6738] Replace synchronized blocks with DCL to reduce contention
Date Wed, 27 Jan 2016 13:08:20 GMT
Repository: cxf
Updated Branches:
  refs/heads/3.1.x-fixes 48aa8e93e -> e7a75b695


[CXF-6738] Replace synchronized blocks with DCL to reduce contention


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

Branch: refs/heads/3.1.x-fixes
Commit: 0384a69b7bc0b4846e89469f974ace534e7734d7
Parents: 48aa8e9
Author: Alessio Soldano <asoldano@redhat.com>
Authored: Thu Jan 7 22:51:53 2016 +0100
Committer: Alessio Soldano <asoldano@redhat.com>
Committed: Wed Jan 27 13:58:56 2016 +0100

----------------------------------------------------------------------
 .../apache/cxf/ws/policy/PolicyEngineImpl.java  | 158 +++++++++++--------
 1 file changed, 91 insertions(+), 67 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cxf/blob/0384a69b/rt/ws/policy/src/main/java/org/apache/cxf/ws/policy/PolicyEngineImpl.java
----------------------------------------------------------------------
diff --git a/rt/ws/policy/src/main/java/org/apache/cxf/ws/policy/PolicyEngineImpl.java b/rt/ws/policy/src/main/java/org/apache/cxf/ws/policy/PolicyEngineImpl.java
index 511a26c..e3af4c9 100644
--- a/rt/ws/policy/src/main/java/org/apache/cxf/ws/policy/PolicyEngineImpl.java
+++ b/rt/ws/policy/src/main/java/org/apache/cxf/ws/policy/PolicyEngineImpl.java
@@ -194,19 +194,22 @@ public class PolicyEngineImpl implements PolicyEngine, BusExtension
{
 
     public EffectivePolicy getEffectiveClientRequestPolicy(EndpointInfo ei, BindingOperationInfo
boi, 
                                                            Conduit c, Message m) {
-        synchronized (ei) {
-            EffectivePolicy effectivePolicy = (EffectivePolicy)boi.getProperty(POLICY_INFO_REQUEST_CLIENT);
-            if (null == effectivePolicy) {
-                EffectivePolicyImpl epi = createOutPolicyInfo();
-                Assertor assertor = PolicyUtils.createAsserter(c);
-                if (m != null) {
-                    boi.setProperty(POLICY_INFO_REQUEST_CLIENT, epi);
+        EffectivePolicy effectivePolicy = (EffectivePolicy)boi.getProperty(POLICY_INFO_REQUEST_CLIENT);
+        if (effectivePolicy == null) {
+            synchronized (ei) {
+                effectivePolicy = (EffectivePolicy)boi.getProperty(POLICY_INFO_REQUEST_CLIENT);
+                if (null == effectivePolicy) {
+                    EffectivePolicyImpl epi = createOutPolicyInfo();
+                    Assertor assertor = PolicyUtils.createAsserter(c);
+                    epi.initialise(ei, boi, this, assertor, true, true, m);
+                    if (m != null) {
+                        boi.setProperty(POLICY_INFO_REQUEST_CLIENT, epi);
+                    }
+                    effectivePolicy = epi;
                 }
-                epi.initialise(ei, boi, this, assertor, true, true, m);
-                effectivePolicy = epi;
             }
-            return effectivePolicy;
         }
+        return effectivePolicy;
     }
 
     public void setEffectiveClientRequestPolicy(EndpointInfo ei, BindingOperationInfo boi,

@@ -220,19 +223,22 @@ public class PolicyEngineImpl implements PolicyEngine, BusExtension
{
                                                             List<List<Assertion>>
incoming, 
                                                             Message m) {
         if (incoming == null) {
-            synchronized (ei) {
-                EffectivePolicy effectivePolicy = (EffectivePolicy)boi.getProperty(POLICY_INFO_RESPONSE_SERVER);
-                if (null == effectivePolicy) {
-                    EffectivePolicyImpl epi = createOutPolicyInfo();
-                    Assertor assertor = PolicyUtils.createAsserter(d);
-                    if (m != null) {
-                        boi.setProperty(POLICY_INFO_RESPONSE_SERVER, epi);
+            EffectivePolicy effectivePolicy = (EffectivePolicy)boi.getProperty(POLICY_INFO_RESPONSE_SERVER);
+            if (effectivePolicy == null) {
+                synchronized (ei) {
+                    effectivePolicy = (EffectivePolicy)boi.getProperty(POLICY_INFO_RESPONSE_SERVER);
+                    if (null == effectivePolicy) {
+                        EffectivePolicyImpl epi = createOutPolicyInfo();
+                        Assertor assertor = PolicyUtils.createAsserter(d);
+                        epi.initialise(ei, boi, this, assertor, false, false, null);
+                        if (m != null) {
+                            boi.setProperty(POLICY_INFO_RESPONSE_SERVER, epi);
+                        }
+                        effectivePolicy = epi;
                     }
-                    epi.initialise(ei, boi, this, assertor, false, false, null);
-                    effectivePolicy = epi;
                 }
-                return effectivePolicy;
-            } 
+            }
+            return effectivePolicy;
         }
         EffectivePolicyImpl epi = createOutPolicyInfo();
         Assertor assertor = PolicyUtils.createAsserter(d);
@@ -258,19 +264,22 @@ public class PolicyEngineImpl implements PolicyEngine, BusExtension
{
             return epi;
         }
         bfi = mapToWrappedBindingFaultInfo(bfi);
-        synchronized (ei) {
-            EffectivePolicy effectivePolicy = (EffectivePolicy)bfi.getProperty(POLICY_INFO_FAULT_SERVER);
-            if (null == effectivePolicy) {
-                EffectivePolicyImpl epi = createOutPolicyInfo();
-                Assertor assertor = PolicyUtils.createAsserter(d);
-                if (m != null) {
-                    bfi.setProperty(POLICY_INFO_FAULT_SERVER, epi);
+        EffectivePolicy effectivePolicy = (EffectivePolicy)bfi.getProperty(POLICY_INFO_FAULT_SERVER);
+        if (effectivePolicy == null) {
+            synchronized (ei) {
+                effectivePolicy = (EffectivePolicy)bfi.getProperty(POLICY_INFO_FAULT_SERVER);
+                if (null == effectivePolicy) {
+                    EffectivePolicyImpl epi = createOutPolicyInfo();
+                    Assertor assertor = PolicyUtils.createAsserter(d);
+                    epi.initialise(ei, boi, bfi, this, assertor, m);
+                    if (m != null) {
+                        bfi.setProperty(POLICY_INFO_FAULT_SERVER, epi);
+                    }
+                    effectivePolicy = epi;
                 }
-                epi.initialise(ei, boi, bfi, this, assertor, m);
-                effectivePolicy = epi;
             }
-            return effectivePolicy;
         }
+        return effectivePolicy;
     }
 
     private BindingFaultInfo mapToWrappedBindingFaultInfo(BindingFaultInfo bfi) {
@@ -299,19 +308,23 @@ public class PolicyEngineImpl implements PolicyEngine, BusExtension
{
         return getEndpointPolicy(ei, false, assertor, m);
     }
 
-    private EndpointPolicy getEndpointPolicy(
+    private EndpointPolicy getEndpointPolicy(//NOPMD
         EndpointInfo ei, 
         boolean isRequestor,
         Assertor assertor,
         Message m) {
-        synchronized (ei) {
-            EndpointPolicy ep = (EndpointPolicy)ei.getProperty(isRequestor ? POLICY_INFO_ENDPOINT_CLIENT

-                            : POLICY_INFO_ENDPOINT_SERVER);
-            if (null != ep) {
-                return ep; 
+        EndpointPolicy ep = (EndpointPolicy)ei.getProperty(isRequestor
+            ? POLICY_INFO_ENDPOINT_CLIENT : POLICY_INFO_ENDPOINT_SERVER);
+        if (ep == null) {
+            synchronized (ei) {
+                ep = (EndpointPolicy)ei.getProperty(isRequestor
+                    ? POLICY_INFO_ENDPOINT_CLIENT : POLICY_INFO_ENDPOINT_SERVER);
+                if (ep == null) {
+                    ep = createEndpointPolicyInfo(ei, isRequestor, assertor, m);
+                }
             }
-            return createEndpointPolicyInfo(ei, isRequestor, assertor, m);
         }
+        return ep;
     }
 
     public void setClientEndpointPolicy(EndpointInfo ei, EndpointPolicy ep) {
@@ -325,18 +338,21 @@ public class PolicyEngineImpl implements PolicyEngine, BusExtension
{
     public EffectivePolicy getEffectiveServerRequestPolicy(EndpointInfo ei, 
                                                            BindingOperationInfo boi, 
                                                            Message m) {
-        synchronized (ei) {
-            EffectivePolicy effectivePolicy = (EffectivePolicy)boi.getProperty(POLICY_INFO_REQUEST_SERVER);
-            if (null == effectivePolicy) {
-                EffectivePolicyImpl epi = createOutPolicyInfo();
-                if (m != null) {
-                    boi.setProperty(POLICY_INFO_REQUEST_SERVER, epi);
+        EffectivePolicy effectivePolicy = (EffectivePolicy)boi.getProperty(POLICY_INFO_REQUEST_SERVER);
+        if (effectivePolicy == null) {
+            synchronized (ei) {
+                effectivePolicy = (EffectivePolicy)boi.getProperty(POLICY_INFO_REQUEST_SERVER);
+                if (null == effectivePolicy) {
+                    EffectivePolicyImpl epi = createOutPolicyInfo();
+                    epi.initialise(ei, boi, this, false, true, m);
+                    if (m != null) {
+                        boi.setProperty(POLICY_INFO_REQUEST_SERVER, epi);
+                    }
+                    effectivePolicy = epi;
                 }
-                epi.initialise(ei, boi, this, false, true, m);
-                effectivePolicy = epi;
             }
-            return effectivePolicy;
         }
+        return effectivePolicy;
     }
 
     public void setEffectiveServerRequestPolicy(EndpointInfo ei, BindingOperationInfo boi,

@@ -347,18 +363,21 @@ public class PolicyEngineImpl implements PolicyEngine, BusExtension
{
     public EffectivePolicy getEffectiveClientResponsePolicy(EndpointInfo ei,
                                                             BindingOperationInfo boi,
                                                             Message m) {
-        synchronized (ei) {
-            EffectivePolicy effectivePolicy = (EffectivePolicy)boi.getProperty(POLICY_INFO_RESPONSE_CLIENT);
-            if (null == effectivePolicy) {
-                EffectivePolicyImpl epi = createOutPolicyInfo();
-                if (m != null) {
-                    boi.setProperty(POLICY_INFO_RESPONSE_CLIENT, epi);
+        EffectivePolicy effectivePolicy = (EffectivePolicy)boi.getProperty(POLICY_INFO_RESPONSE_CLIENT);
+        if (effectivePolicy == null) {
+            synchronized (ei) {
+                effectivePolicy = (EffectivePolicy)boi.getProperty(POLICY_INFO_RESPONSE_CLIENT);
+                if (null == effectivePolicy) {
+                    EffectivePolicyImpl epi = createOutPolicyInfo();
+                    epi.initialise(ei, boi, this, true, false, m);
+                    if (m != null) {
+                        boi.setProperty(POLICY_INFO_RESPONSE_CLIENT, epi);
+                    }
+                    effectivePolicy = epi;
                 }
-                epi.initialise(ei, boi, this, true, false, m);
-                effectivePolicy = epi;
             }
-            return effectivePolicy;
         }
+        return effectivePolicy;
     }
 
     public void setEffectiveClientResponsePolicy(EndpointInfo ei, BindingOperationInfo boi,

@@ -370,21 +389,26 @@ public class PolicyEngineImpl implements PolicyEngine, BusExtension
{
                                                          BindingOperationInfo boi,
                                                          BindingFaultInfo bfi,
                                                          Message m) {
-        synchronized (ei) {
-            EffectivePolicy effectivePolicy = null;
-            if (bfi != null) {
-                effectivePolicy = (EffectivePolicy)bfi.getProperty(POLICY_INFO_FAULT_CLIENT);
-            }
-            if (null == effectivePolicy) {
-                EffectivePolicyImpl epi = createOutPolicyInfo();
+        EffectivePolicy effectivePolicy = null;
+        if (bfi != null) {
+            effectivePolicy = (EffectivePolicy)bfi.getProperty(POLICY_INFO_FAULT_CLIENT);
+        }
+        if (effectivePolicy == null) {
+            synchronized (ei) {
                 if (bfi != null) {
-                    bfi.setProperty(POLICY_INFO_FAULT_CLIENT, epi);
+                    effectivePolicy = (EffectivePolicy)bfi.getProperty(POLICY_INFO_FAULT_CLIENT);
+                }
+                if (null == effectivePolicy) {
+                    EffectivePolicyImpl epi = createOutPolicyInfo();
+                    epi.initialisePolicy(ei, boi, bfi, this, m);
+                    if (bfi != null) {
+                        bfi.setProperty(POLICY_INFO_FAULT_CLIENT, epi);
+                    }
+                    effectivePolicy = epi;
                 }
-                epi.initialisePolicy(ei, boi, bfi, this, m);
-                effectivePolicy = epi;
             }
-            return effectivePolicy;
         }
+        return effectivePolicy;
     }
 
     public void setEffectiveClientFaultPolicy(EndpointInfo ei, BindingFaultInfo bfi, EffectivePolicy
ep) {


Mime
View raw message