diff --git a/codec-http/src/main/java/io/netty/handler/codec/http/websocketx/WebSocketServerProtocolHandler.java b/codec-http/src/main/java/io/netty/handler/codec/http/websocketx/WebSocketServerProtocolHandler.java index 92a5bb55ad..9cd59bde81 100644 --- a/codec-http/src/main/java/io/netty/handler/codec/http/websocketx/WebSocketServerProtocolHandler.java +++ b/codec-http/src/main/java/io/netty/handler/codec/http/websocketx/WebSocketServerProtocolHandler.java @@ -16,6 +16,7 @@ package io.netty.handler.codec.http.websocketx; import io.netty.buffer.Unpooled; +import io.netty.channel.Channel; import io.netty.channel.ChannelFutureListener; import io.netty.channel.ChannelHandler; import io.netty.channel.ChannelHandlerContext; @@ -102,7 +103,7 @@ public class WebSocketServerProtocolHandler extends WebSocketProtocolHandler { @Override protected void decode(ChannelHandlerContext ctx, WebSocketFrame frame, List out) throws Exception { if (frame instanceof CloseWebSocketFrame) { - WebSocketServerHandshaker handshaker = getHandshaker(ctx); + WebSocketServerHandshaker handshaker = getHandshaker(ctx.channel()); if (handshaker != null) { frame.retain(); handshaker.close(ctx.channel(), (CloseWebSocketFrame) frame); @@ -125,12 +126,12 @@ public class WebSocketServerProtocolHandler extends WebSocketProtocolHandler { } } - static WebSocketServerHandshaker getHandshaker(ChannelHandlerContext ctx) { - return ctx.attr(HANDSHAKER_ATTR_KEY).get(); + static WebSocketServerHandshaker getHandshaker(Channel channel) { + return channel.attr(HANDSHAKER_ATTR_KEY).get(); } - static void setHandshaker(ChannelHandlerContext ctx, WebSocketServerHandshaker handshaker) { - ctx.attr(HANDSHAKER_ATTR_KEY).set(handshaker); + static void setHandshaker(Channel channel, WebSocketServerHandshaker handshaker) { + channel.attr(HANDSHAKER_ATTR_KEY).set(handshaker); } static ChannelHandler forbiddenHttpRequestResponder() { diff --git a/codec-http/src/main/java/io/netty/handler/codec/http/websocketx/WebSocketServerProtocolHandshakeHandler.java b/codec-http/src/main/java/io/netty/handler/codec/http/websocketx/WebSocketServerProtocolHandshakeHandler.java index 54356ccb8a..3ecd853ff5 100644 --- a/codec-http/src/main/java/io/netty/handler/codec/http/websocketx/WebSocketServerProtocolHandshakeHandler.java +++ b/codec-http/src/main/java/io/netty/handler/codec/http/websocketx/WebSocketServerProtocolHandshakeHandler.java @@ -78,7 +78,7 @@ class WebSocketServerProtocolHandshakeHandler } } }); - WebSocketServerProtocolHandler.setHandshaker(ctx, handshaker); + WebSocketServerProtocolHandler.setHandshaker(ctx.channel(), handshaker); ctx.pipeline().replace(this, "WS403Responder", WebSocketServerProtocolHandler.forbiddenHttpRequestResponder()); } diff --git a/codec-http/src/test/java/io/netty/handler/codec/http/websocketx/WebSocketServerProtocolHandlerTest.java b/codec-http/src/test/java/io/netty/handler/codec/http/websocketx/WebSocketServerProtocolHandlerTest.java index bf89cf539e..bedc82c2af 100644 --- a/codec-http/src/test/java/io/netty/handler/codec/http/websocketx/WebSocketServerProtocolHandlerTest.java +++ b/codec-http/src/test/java/io/netty/handler/codec/http/websocketx/WebSocketServerProtocolHandlerTest.java @@ -55,7 +55,7 @@ public class WebSocketServerProtocolHandlerTest { ChannelHandlerContext handshakerCtx = ch.pipeline().context(WebSocketServerProtocolHandshakeHandler.class); writeUpgradeRequest(ch); assertEquals(SWITCHING_PROTOCOLS, ReferenceCountUtil.releaseLater(responses.remove()).getStatus()); - assertNotNull(WebSocketServerProtocolHandler.getHandshaker(handshakerCtx)); + assertNotNull(WebSocketServerProtocolHandler.getHandshaker(handshakerCtx.channel())); } @Test