From cdd2108dd1c83985c0a5f161594ee09ea48e16ce Mon Sep 17 00:00:00 2001 From: "Hiram R. Chirino" Date: Mon, 17 Mar 2008 16:42:09 +0000 Subject: [PATCH] Just making it a little more thread safe. git-svn-id: https://svn.apache.org/repos/asf/activemq/trunk@637965 13f79535-47bb-0310-9956-ffa450edef68 --- .../activemq/transport/failover/FailoverTransport.java | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/activemq-core/src/main/java/org/apache/activemq/transport/failover/FailoverTransport.java b/activemq-core/src/main/java/org/apache/activemq/transport/failover/FailoverTransport.java index 748d5be22a..a18e298fa3 100755 --- a/activemq-core/src/main/java/org/apache/activemq/transport/failover/FailoverTransport.java +++ b/activemq-core/src/main/java/org/apache/activemq/transport/failover/FailoverTransport.java @@ -34,6 +34,7 @@ import java.util.concurrent.atomic.AtomicReference; import org.apache.activemq.command.BrokerInfo; import org.apache.activemq.command.Command; import org.apache.activemq.command.ConnectionControl; +import org.apache.activemq.command.Message; import org.apache.activemq.command.RemoveInfo; import org.apache.activemq.command.Response; import org.apache.activemq.state.ConnectionStateTracker; @@ -385,6 +386,7 @@ public class FailoverTransport implements CompositeTransport { public void oneway(Object o) throws IOException { + Command command = (Command)o; Exception error = null; try { @@ -409,7 +411,8 @@ public class FailoverTransport implements CompositeTransport { try { // Wait for transport to be connected. - while (connectedTransport.get() == null && !disposed && connectionFailure == null) { + Transport transport = connectedTransport.get(); + while (transport == null && !disposed && connectionFailure == null) { LOG.trace("Waiting for transport to reconnect."); try { reconnectMutex.wait(1000); @@ -417,9 +420,10 @@ public class FailoverTransport implements CompositeTransport { Thread.currentThread().interrupt(); LOG.debug("Interupted: " + e, e); } + transport = connectedTransport.get(); } - if (connectedTransport.get() == null) { + if (transport == null) { // Previous loop may have exited due to use being // disposed. if (disposed) { @@ -445,7 +449,7 @@ public class FailoverTransport implements CompositeTransport { // Send the message. try { - connectedTransport.get().oneway(command); + transport.oneway(command); stateTracker.trackBack(command); } catch (IOException e) {