You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@cxf.apache.org by co...@apache.org on 2018/10/23 10:57:01 UTC

[cxf] branch master updated (fe8c618 -> 55afdc9)

This is an automated email from the ASF dual-hosted git repository.

coheigea pushed a change to branch master
in repository https://gitbox.apache.org/repos/asf/cxf.git.


    from fe8c618  CollectionUtils improvements
     new 0ae26aa  CXF-7882 - FailoverTargetSelector uses the Exchange as the key in the inProgress map
     new 55afdc9  CXF-7882 - Making some additional changes on master only

The 2 revisions listed above as "new" are entirely new to this
repository and will be described in separate emails.  The revisions
listed as "add" were already present in the repository and have only
been added to this reference.


Summary of changes:
 .../clustering/CircuitBreakerTargetSelector.java   |  4 +-
 .../cxf/clustering/FailoverTargetSelector.java     | 49 ++++++----------------
 .../clustering/LoadDistributorTargetSelector.java  |  4 +-
 3 files changed, 17 insertions(+), 40 deletions(-)


[cxf] 01/02: CXF-7882 - FailoverTargetSelector uses the Exchange as the key in the inProgress map

Posted by co...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

coheigea pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/cxf.git

commit 0ae26aa4cdad1da742645c61c9f71eda48fd6169
Author: Colm O hEigeartaigh <co...@apache.org>
AuthorDate: Tue Oct 23 10:36:36 2018 +0100

    CXF-7882 - FailoverTargetSelector uses the Exchange as the key in the inProgress map
---
 .../cxf/clustering/CircuitBreakerTargetSelector.java       |  2 +-
 .../org/apache/cxf/clustering/FailoverTargetSelector.java  | 14 ++++++++------
 .../cxf/clustering/LoadDistributorTargetSelector.java      |  2 +-
 3 files changed, 10 insertions(+), 8 deletions(-)

diff --git a/rt/features/clustering/src/main/java/org/apache/cxf/clustering/CircuitBreakerTargetSelector.java b/rt/features/clustering/src/main/java/org/apache/cxf/clustering/CircuitBreakerTargetSelector.java
index 3010351..17e30f6 100644
--- a/rt/features/clustering/src/main/java/org/apache/cxf/clustering/CircuitBreakerTargetSelector.java
+++ b/rt/features/clustering/src/main/java/org/apache/cxf/clustering/CircuitBreakerTargetSelector.java
@@ -117,7 +117,7 @@ public class CircuitBreakerTargetSelector extends FailoverTargetSelector {
         }
         Exchange exchange = message.getExchange();
         InvocationKey key = new InvocationKey(exchange);
-        InvocationContext invocation = inProgress.get(key);
+        InvocationContext invocation = getInvocationContext(key);
         if (invocation != null && !invocation.getContext().containsKey(IS_SELECTED)) {
             final String address = (String) message.get(Message.ENDPOINT_ADDRESS);
 
diff --git a/rt/features/clustering/src/main/java/org/apache/cxf/clustering/FailoverTargetSelector.java b/rt/features/clustering/src/main/java/org/apache/cxf/clustering/FailoverTargetSelector.java
index d468ae1..8b0d532 100644
--- a/rt/features/clustering/src/main/java/org/apache/cxf/clustering/FailoverTargetSelector.java
+++ b/rt/features/clustering/src/main/java/org/apache/cxf/clustering/FailoverTargetSelector.java
@@ -51,8 +51,7 @@ public class FailoverTargetSelector extends AbstractConduitSelector {
     private static final String COMPLETE_IF_SERVICE_NOT_AVAIL_PROPERTY =
         "org.apache.cxf.transport.complete_if_service_not_available";
 
-    protected ConcurrentHashMap<InvocationKey, InvocationContext> inProgress
-        = new ConcurrentHashMap<InvocationKey, InvocationContext>();
+    protected ConcurrentHashMap<String, InvocationContext> inProgress = new ConcurrentHashMap<>();
     protected FailoverStrategy failoverStrategy;
     private boolean supportNotAvailableErrorsOnly = true;
     private String clientBootstrapAddress;
@@ -112,7 +111,7 @@ public class FailoverTargetSelector extends AbstractConduitSelector {
                                       bindingOperationInfo,
                                       params,
                                       context);
-            inProgress.putIfAbsent(key, invocation);
+            inProgress.putIfAbsent(String.valueOf(key.hashCode()), invocation);
         }
     }
 
@@ -138,7 +137,10 @@ public class FailoverTargetSelector extends AbstractConduitSelector {
     }
 
     protected InvocationContext getInvocationContext(InvocationKey key) {
-        return inProgress.get(key);
+        if (key != null) {
+            return inProgress.get(String.valueOf(key.hashCode()));
+        }
+        return null;
     }
 
     /**
@@ -175,7 +177,7 @@ public class FailoverTargetSelector extends AbstractConduitSelector {
         }
 
         if (!failover) {
-            inProgress.remove(key);
+            inProgress.remove(String.valueOf(key.hashCode()));
             doComplete(exchange);
         }
     }
@@ -405,7 +407,7 @@ public class FailoverTargetSelector extends AbstractConduitSelector {
 
                 Exchange exchange = message.getExchange();
                 InvocationKey key = new InvocationKey(exchange);
-                InvocationContext invocation = inProgress.get(key);
+                InvocationContext invocation = getInvocationContext(key);
                 if (invocation != null) {
                     overrideAddressProperty(invocation.getContext(),
                                             cond.getTarget().getAddress().getValue());
diff --git a/rt/features/clustering/src/main/java/org/apache/cxf/clustering/LoadDistributorTargetSelector.java b/rt/features/clustering/src/main/java/org/apache/cxf/clustering/LoadDistributorTargetSelector.java
index 5ef66f5..76f49c9 100644
--- a/rt/features/clustering/src/main/java/org/apache/cxf/clustering/LoadDistributorTargetSelector.java
+++ b/rt/features/clustering/src/main/java/org/apache/cxf/clustering/LoadDistributorTargetSelector.java
@@ -107,7 +107,7 @@ public class LoadDistributorTargetSelector extends FailoverTargetSelector {
         }
         Exchange exchange = message.getExchange();
         InvocationKey key = new InvocationKey(exchange);
-        InvocationContext invocation = inProgress.get(key);
+        InvocationContext invocation = getInvocationContext(key);
         if ((invocation != null) && !invocation.getContext().containsKey(IS_DISTRIBUTED)) {
             Endpoint target = getDistributionTarget(exchange, invocation);
             if (target != null) {


[cxf] 02/02: CXF-7882 - Making some additional changes on master only

Posted by co...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

coheigea pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/cxf.git

commit 55afdc9373257d8c111468926c7278b4e9b28a61
Author: Colm O hEigeartaigh <co...@apache.org>
AuthorDate: Tue Oct 23 10:48:30 2018 +0100

    CXF-7882 - Making some additional changes on master only
---
 .../clustering/CircuitBreakerTargetSelector.java   |  2 +-
 .../cxf/clustering/FailoverTargetSelector.java     | 47 +++++-----------------
 .../clustering/LoadDistributorTargetSelector.java  |  2 +-
 3 files changed, 13 insertions(+), 38 deletions(-)

diff --git a/rt/features/clustering/src/main/java/org/apache/cxf/clustering/CircuitBreakerTargetSelector.java b/rt/features/clustering/src/main/java/org/apache/cxf/clustering/CircuitBreakerTargetSelector.java
index 17e30f6..3e8e68b 100644
--- a/rt/features/clustering/src/main/java/org/apache/cxf/clustering/CircuitBreakerTargetSelector.java
+++ b/rt/features/clustering/src/main/java/org/apache/cxf/clustering/CircuitBreakerTargetSelector.java
@@ -116,7 +116,7 @@ public class CircuitBreakerTargetSelector extends FailoverTargetSelector {
             return c;
         }
         Exchange exchange = message.getExchange();
-        InvocationKey key = new InvocationKey(exchange);
+        String key = String.valueOf(System.identityHashCode(exchange));
         InvocationContext invocation = getInvocationContext(key);
         if (invocation != null && !invocation.getContext().containsKey(IS_SELECTED)) {
             final String address = (String) message.get(Message.ENDPOINT_ADDRESS);
diff --git a/rt/features/clustering/src/main/java/org/apache/cxf/clustering/FailoverTargetSelector.java b/rt/features/clustering/src/main/java/org/apache/cxf/clustering/FailoverTargetSelector.java
index 8b0d532..c2abc28 100644
--- a/rt/features/clustering/src/main/java/org/apache/cxf/clustering/FailoverTargetSelector.java
+++ b/rt/features/clustering/src/main/java/org/apache/cxf/clustering/FailoverTargetSelector.java
@@ -51,10 +51,11 @@ public class FailoverTargetSelector extends AbstractConduitSelector {
     private static final String COMPLETE_IF_SERVICE_NOT_AVAIL_PROPERTY =
         "org.apache.cxf.transport.complete_if_service_not_available";
 
-    protected ConcurrentHashMap<String, InvocationContext> inProgress = new ConcurrentHashMap<>();
     protected FailoverStrategy failoverStrategy;
+    private ConcurrentHashMap<String, InvocationContext> inProgress = new ConcurrentHashMap<>();
     private boolean supportNotAvailableErrorsOnly = true;
     private String clientBootstrapAddress;
+
     /**
      * Normal constructor.
      */
@@ -88,7 +89,7 @@ public class FailoverTargetSelector extends AbstractConduitSelector {
         Exchange exchange = message.getExchange();
         setupExchangeExceptionProperties(exchange);
 
-        InvocationKey key = new InvocationKey(exchange);
+        String key = String.valueOf(System.identityHashCode(exchange));
         if (getInvocationContext(key) == null) {
 
             if (getClientBootstrapAddress() != null
@@ -111,7 +112,7 @@ public class FailoverTargetSelector extends AbstractConduitSelector {
                                       bindingOperationInfo,
                                       params,
                                       context);
-            inProgress.putIfAbsent(String.valueOf(key.hashCode()), invocation);
+            inProgress.putIfAbsent(key, invocation);
         }
     }
 
@@ -136,9 +137,9 @@ public class FailoverTargetSelector extends AbstractConduitSelector {
         return getSelectedConduit(message);
     }
 
-    protected InvocationContext getInvocationContext(InvocationKey key) {
+    protected InvocationContext getInvocationContext(String key) {
         if (key != null) {
-            return inProgress.get(String.valueOf(key.hashCode()));
+            return inProgress.get(key);
         }
         return null;
     }
@@ -149,7 +150,7 @@ public class FailoverTargetSelector extends AbstractConduitSelector {
      * @param exchange represents the completed MEP
      */
     public void complete(Exchange exchange) {
-        InvocationKey key = new InvocationKey(exchange);
+        String key = String.valueOf(System.identityHashCode(exchange));
         InvocationContext invocation = getInvocationContext(key);
         if (invocation == null) {
             super.complete(exchange);
@@ -177,7 +178,7 @@ public class FailoverTargetSelector extends AbstractConduitSelector {
         }
 
         if (!failover) {
-            inProgress.remove(String.valueOf(key.hashCode()));
+            inProgress.remove(key);
             doComplete(exchange);
         }
     }
@@ -406,7 +407,7 @@ public class FailoverTargetSelector extends AbstractConduitSelector {
                 message.put(Message.REQUEST_URI, endpointAddress);
 
                 Exchange exchange = message.getExchange();
-                InvocationKey key = new InvocationKey(exchange);
+                String key = String.valueOf(System.identityHashCode(exchange));
                 InvocationContext invocation = getInvocationContext(key);
                 if (invocation != null) {
                     overrideAddressProperty(invocation.getContext(),
@@ -434,36 +435,10 @@ public class FailoverTargetSelector extends AbstractConduitSelector {
         this.clientBootstrapAddress = clientBootstrapAddress;
     }
 
-    protected InvocationKey getInvocationKey(Exchange e) {
-        return new InvocationKey(e);
-    }
-
-    /**
-     * Used to wrap an Exchange for usage as a Map key. The raw Exchange
-     * is not a suitable key type, as the hashCode is computed from its
-     * current contents, which may obviously change over the lifetime of
-     * an invocation.
-     */
-    protected static class InvocationKey {
-        private Exchange exchange;
-
-        protected InvocationKey(Exchange ex) {
-            exchange = ex;
-        }
-
-        @Override
-        public int hashCode() {
-            return System.identityHashCode(exchange);
-        }
-
-        @Override
-        public boolean equals(Object o) {
-            return o instanceof InvocationKey
-                   && exchange == ((InvocationKey)o).exchange;
-        }
+    protected String getInvocationKey(Exchange e) {
+        return String.valueOf(System.identityHashCode(e));
     }
 
-
     /**
      * Records the context of an invocation.
      */
diff --git a/rt/features/clustering/src/main/java/org/apache/cxf/clustering/LoadDistributorTargetSelector.java b/rt/features/clustering/src/main/java/org/apache/cxf/clustering/LoadDistributorTargetSelector.java
index 76f49c9..b1844fc 100644
--- a/rt/features/clustering/src/main/java/org/apache/cxf/clustering/LoadDistributorTargetSelector.java
+++ b/rt/features/clustering/src/main/java/org/apache/cxf/clustering/LoadDistributorTargetSelector.java
@@ -106,7 +106,7 @@ public class LoadDistributorTargetSelector extends FailoverTargetSelector {
             return c;
         }
         Exchange exchange = message.getExchange();
-        InvocationKey key = new InvocationKey(exchange);
+        String key = String.valueOf(System.identityHashCode(exchange));
         InvocationContext invocation = getInvocationContext(key);
         if ((invocation != null) && !invocation.getContext().containsKey(IS_DISTRIBUTED)) {
             Endpoint target = getDistributionTarget(exchange, invocation);