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:03 UTC
[cxf] 02/02: CXF-7882 - Making some additional changes on master
only
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);