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:02 UTC
[cxf] 01/02: CXF-7882 - FailoverTargetSelector uses the Exchange as
the key in the inProgress map
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) {