From 3e7ebc2368d378176ac257977e3b4dfc3a890241 Mon Sep 17 00:00:00 2001 From: Robert Davies Date: Tue, 31 Jan 2006 16:31:21 +0000 Subject: [PATCH] Add a check to the iterate() so that on failover - it's not possible to iterate for ever if the transport has actually been stopped git-svn-id: https://svn.apache.org/repos/asf/incubator/activemq/trunk@373862 13f79535-47bb-0310-9956-ffa450edef68 --- .../transport/failover/FailoverTransport.java | 29 +++++++++---------- 1 file changed, 14 insertions(+), 15 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 681c9524ef..3053030b87 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 @@ -170,22 +170,21 @@ public class FailoverTransport implements CompositeTransport { } } - - try { - log.debug("Waiting " + reconnectDelay + " ms before attempting connection. "); - Thread.sleep(reconnectDelay); + if(!disposed){ + try{ + log.debug("Waiting "+reconnectDelay+" ms before attempting connection. "); + Thread.sleep(reconnectDelay); + }catch(InterruptedException e1){ + Thread.currentThread().interrupt(); + } + if(useExponentialBackOff){ + // Exponential increment of reconnect delay. + reconnectDelay*=backOffMultiplier; + if(reconnectDelay>maxReconnectDelay) + reconnectDelay=maxReconnectDelay; + } } - catch (InterruptedException e1) { - Thread.currentThread().interrupt(); - } - - if (useExponentialBackOff) { - // Exponential increment of reconnect delay. - reconnectDelay *= backOffMultiplier; - if (reconnectDelay > maxReconnectDelay) - reconnectDelay = maxReconnectDelay; - } - return true; + return !disposed; } });