Clean up connection resources on failed connect.

This commit is contained in:
Timothy Bish 2016-12-21 17:19:05 -05:00
parent ef97b67f00
commit 8a34ca0ec7
1 changed files with 14 additions and 6 deletions

View File

@ -165,6 +165,7 @@ public class AmqpConnection extends AmqpAbstractResource<Connection> implements
}
});
try {
if (connectTimeout <= 0) {
future.sync();
} else {
@ -173,6 +174,13 @@ public class AmqpConnection extends AmqpAbstractResource<Connection> implements
throw new IOException("Failed to connect after configured timeout.");
}
}
} catch (Throwable error) {
try {
close();
} catch (Throwable ignore) {}
throw error;
}
}
}