[#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:
parent
42de9d446f
commit
1f3bae78c5
@ -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());
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user