activemq-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From tab...@apache.org
Subject activemq git commit: Clean up connection resources on failed connect.
Date Wed, 21 Dec 2016 22:19:14 GMT
Repository: activemq
Updated Branches:
  refs/heads/master ef97b67f0 -> 8a34ca0ec


Clean up connection resources on failed connect.

Project: http://git-wip-us.apache.org/repos/asf/activemq/repo
Commit: http://git-wip-us.apache.org/repos/asf/activemq/commit/8a34ca0e
Tree: http://git-wip-us.apache.org/repos/asf/activemq/tree/8a34ca0e
Diff: http://git-wip-us.apache.org/repos/asf/activemq/diff/8a34ca0e

Branch: refs/heads/master
Commit: 8a34ca0ec742f9d3e71211802ac235a7ae88789b
Parents: ef97b67
Author: Timothy Bish <tabish121@gmail.com>
Authored: Wed Dec 21 17:19:05 2016 -0500
Committer: Timothy Bish <tabish121@gmail.com>
Committed: Wed Dec 21 17:19:05 2016 -0500

----------------------------------------------------------------------
 .../transport/amqp/client/AmqpConnection.java   | 20 ++++++++++++++------
 1 file changed, 14 insertions(+), 6 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/activemq/blob/8a34ca0e/activemq-amqp/src/test/java/org/apache/activemq/transport/amqp/client/AmqpConnection.java
----------------------------------------------------------------------
diff --git a/activemq-amqp/src/test/java/org/apache/activemq/transport/amqp/client/AmqpConnection.java
b/activemq-amqp/src/test/java/org/apache/activemq/transport/amqp/client/AmqpConnection.java
index c6c994d..c252d1f 100644
--- a/activemq-amqp/src/test/java/org/apache/activemq/transport/amqp/client/AmqpConnection.java
+++ b/activemq-amqp/src/test/java/org/apache/activemq/transport/amqp/client/AmqpConnection.java
@@ -165,13 +165,21 @@ public class AmqpConnection extends AmqpAbstractResource<Connection>
implements
                 }
             });
 
-            if (connectTimeout <= 0) {
-                future.sync();
-            } else {
-                future.sync(connectTimeout, TimeUnit.MILLISECONDS);
-                if (getEndpoint().getRemoteState() != EndpointState.ACTIVE) {
-                    throw new IOException("Failed to connect after configured timeout.");
+            try {
+                if (connectTimeout <= 0) {
+                    future.sync();
+                } else {
+                    future.sync(connectTimeout, TimeUnit.MILLISECONDS);
+                    if (getEndpoint().getRemoteState() != EndpointState.ACTIVE) {
+                        throw new IOException("Failed to connect after configured timeout.");
+                    }
                 }
+            } catch (Throwable error) {
+                try {
+                    close();
+                } catch (Throwable ignore) {}
+
+                throw error;
             }
         }
     }


Mime
View raw message