Fix the leak in the WebSocketClientProtocolHandshakeHandler
Motivation: The WebSocketClientProtocolHandshakeHandler never releases the received handshake response. Modification: Release the message in a finally block. Result: No more leak
This commit is contained in:
parent
b9e507c9cc
commit
30db808d0f
@ -51,13 +51,18 @@ class WebSocketClientProtocolHandshakeHandler extends ChannelHandlerAdapter {
|
||||
return;
|
||||
}
|
||||
|
||||
if (!handshaker.isHandshakeComplete()) {
|
||||
handshaker.finishHandshake(ctx.channel(), (FullHttpResponse) msg);
|
||||
ctx.fireUserEventTriggered(
|
||||
WebSocketClientProtocolHandler.ClientHandshakeStateEvent.HANDSHAKE_COMPLETE);
|
||||
ctx.pipeline().remove(this);
|
||||
return;
|
||||
FullHttpResponse response = (FullHttpResponse) msg;
|
||||
try {
|
||||
if (!handshaker.isHandshakeComplete()) {
|
||||
handshaker.finishHandshake(ctx.channel(), response);
|
||||
ctx.fireUserEventTriggered(
|
||||
WebSocketClientProtocolHandler.ClientHandshakeStateEvent.HANDSHAKE_COMPLETE);
|
||||
ctx.pipeline().remove(this);
|
||||
return;
|
||||
}
|
||||
throw new IllegalStateException("WebSocketClientHandshaker should have been non finished yet");
|
||||
} finally {
|
||||
response.release();
|
||||
}
|
||||
throw new IllegalStateException("WebSocketClientHandshaker should have been non finished yet");
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user