[#5553] SimpleChannelPool#notifyConnect() may leak Channels

Motivation:

The SimpleChannelPool#notifyConnect() method will leak Channels if the user cancelled the Promise in between.

Modifications:

Release the channel if the Promise was complete before.

Result:

No more channel leaks.
This commit is contained in:
Norman Maurer 2016-07-19 20:55:44 +02:00
parent d262f7c189
commit b8400f9628

View File

@ -154,9 +154,13 @@ public class SimpleChannelPool implements ChannelPool {
return promise;
}
private static void notifyConnect(ChannelFuture future, Promise<Channel> promise) {
private void notifyConnect(ChannelFuture future, Promise<Channel> promise) {
if (future.isSuccess()) {
promise.setSuccess(future.channel());
Channel channel = future.channel();
if (!promise.trySuccess(channel)) {
// Promise was completed in the meantime (like cancelled), just release the channel again
release(channel);
}
} else {
promise.setFailure(future.cause());
}