mirror of https://github.com/apache/activemq.git
Clean up connection resources on failed connect.
This commit is contained in:
parent
ef97b67f00
commit
8a34ca0ec7
|
@ -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;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue