Skip to content

Commit

Permalink
[netty#5553] SimpleChannelPool#notifyConnect() may leak Channels
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
normanmaurer authored and liuzhengyang committed Sep 10, 2017
1 parent 7eb3fb5 commit ad81907
Showing 1 changed file with 6 additions and 2 deletions.
Expand Up @@ -154,9 +154,13 @@ public void run() {
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());
}
Expand Down

0 comments on commit ad81907

Please sign in to comment.