You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@qpid.apache.org by ro...@apache.org on 2017/07/19 16:16:13 UTC
qpid-jms git commit: QPIDJMS-302: use an AtomicReference to track the
exception/failure status rather than separate fields susceptible to races
Repository: qpid-jms
Updated Branches:
refs/heads/master e249763c0 -> cde08706b
QPIDJMS-302: use an AtomicReference to track the exception/failure status rather than separate fields susceptible to races
Project: http://git-wip-us.apache.org/repos/asf/qpid-jms/repo
Commit: http://git-wip-us.apache.org/repos/asf/qpid-jms/commit/cde08706
Tree: http://git-wip-us.apache.org/repos/asf/qpid-jms/tree/cde08706
Diff: http://git-wip-us.apache.org/repos/asf/qpid-jms/diff/cde08706
Branch: refs/heads/master
Commit: cde08706b09d74931bc96fcd55d7bf24db960dce
Parents: e249763
Author: Robert Gemmell <ro...@apache.org>
Authored: Wed Jul 19 17:14:10 2017 +0100
Committer: Robert Gemmell <ro...@apache.org>
Committed: Wed Jul 19 17:14:10 2017 +0100
----------------------------------------------------------------------
.../java/org/apache/qpid/jms/JmsConnection.java | 23 +++++++++-----------
1 file changed, 10 insertions(+), 13 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/qpid-jms/blob/cde08706/qpid-jms-client/src/main/java/org/apache/qpid/jms/JmsConnection.java
----------------------------------------------------------------------
diff --git a/qpid-jms-client/src/main/java/org/apache/qpid/jms/JmsConnection.java b/qpid-jms-client/src/main/java/org/apache/qpid/jms/JmsConnection.java
index 5fade17..d3a77c7 100644
--- a/qpid-jms-client/src/main/java/org/apache/qpid/jms/JmsConnection.java
+++ b/qpid-jms-client/src/main/java/org/apache/qpid/jms/JmsConnection.java
@@ -28,6 +28,7 @@ import java.util.concurrent.ThreadPoolExecutor;
import java.util.concurrent.TimeUnit;
import java.util.concurrent.atomic.AtomicBoolean;
import java.util.concurrent.atomic.AtomicLong;
+import java.util.concurrent.atomic.AtomicReference;
import javax.jms.Connection;
import javax.jms.ConnectionConsumer;
@@ -96,11 +97,10 @@ public class JmsConnection implements AutoCloseable, Connection, TopicConnection
private final AtomicBoolean closed = new AtomicBoolean();
private final AtomicBoolean closing = new AtomicBoolean();
private final AtomicBoolean started = new AtomicBoolean();
- private final AtomicBoolean failed = new AtomicBoolean();
+ private final AtomicReference<IOException> failureCause = new AtomicReference<>();
private final JmsConnectionInfo connectionInfo;
private final ThreadPoolExecutor executor;
- private volatile IOException firstFailureError;
private ExceptionListener exceptionListener;
private JmsMessageFactory messageFactory;
private Provider provider;
@@ -186,7 +186,7 @@ public class JmsConnection implements AutoCloseable, Connection, TopicConnection
try {
- if (!closed.get() && !failed.get()) {
+ if (!closed.get() && !isFailed()) {
// do not fail if already closed as specified by the JMS specification.
doStop(false);
}
@@ -203,7 +203,7 @@ public class JmsConnection implements AutoCloseable, Connection, TopicConnection
session.shutdown();
}
- if (isConnected() && !failed.get()) {
+ if (isConnected() && !isFailed()) {
ProviderFuture request = new ProviderFuture();
requests.put(request, request);
try {
@@ -272,7 +272,7 @@ public class JmsConnection implements AutoCloseable, Connection, TopicConnection
session.shutdown(cause);
}
- if (isConnected() && !failed.get() && !closing.get()) {
+ if (isConnected() && !isFailed() && !closing.get()) {
destroyResource(connectionInfo);
}
@@ -554,8 +554,8 @@ public class JmsConnection implements AutoCloseable, Connection, TopicConnection
protected void checkClosedOrFailed() throws JMSException {
checkClosed();
- if (failed.get()) {
- throw new JmsConnectionFailedException(firstFailureError);
+ if (failureCause.get() != null) {
+ throw new JmsConnectionFailedException(failureCause.get());
}
}
@@ -1029,7 +1029,7 @@ public class JmsConnection implements AutoCloseable, Connection, TopicConnection
}
public boolean isFailed() {
- return failed.get();
+ return failureCause.get() != null;
}
public JmsConnectionId getId() {
@@ -1417,10 +1417,7 @@ public class JmsConnection implements AutoCloseable, Connection, TopicConnection
}
}
- protected void providerFailed(IOException error) {
- failed.set(true);
- if (firstFailureError == null) {
- firstFailureError = error;
- }
+ protected void providerFailed(IOException cause) {
+ failureCause.compareAndSet(null, cause);
}
}
---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@qpid.apache.org
For additional commands, e-mail: commits-help@qpid.apache.org