Fix resource leaks in WebSocketServerProtocolHandler

- Related: #1975
This commit is contained in:
Trustin Lee 2014-02-06 21:23:10 -08:00
parent 8738bc4ae7
commit 2b769c6daf

View File

@ -94,8 +94,12 @@ public class WebSocketServerProtocolHandler extends WebSocketProtocolHandler {
protected void decode(ChannelHandlerContext ctx, WebSocketFrame frame, List<Object> out) throws Exception {
if (frame instanceof CloseWebSocketFrame) {
WebSocketServerHandshaker handshaker = getHandshaker(ctx);
frame.retain();
handshaker.close(ctx.channel(), (CloseWebSocketFrame) frame);
if (handshaker != null) {
frame.retain();
handshaker.close(ctx.channel(), (CloseWebSocketFrame) frame);
} else {
ctx.writeAndFlush(Unpooled.EMPTY_BUFFER).addListener(ChannelFutureListener.CLOSE);
}
return;
}
super.decode(ctx, frame, out);