From f7f19c31fc2d366d5ac20d01f21219b81e6b9a5e Mon Sep 17 00:00:00 2001 From: Maksym Ostroverkhov Date: Fri, 24 May 2024 16:42:53 +0300 Subject: [PATCH] Server/ClientProtocolHandler: override isSharable() to get rid of unnecessary reflection, thread locals and wasted memory. --- .../http/websocketx/WebSocketClientProtocolHandler.java | 5 +++++ .../http/websocketx/WebSocketServerProtocolHandler.java | 5 +++++ 2 files changed, 10 insertions(+) diff --git a/netty-websocket-http1/src/main/java/com/jauntsdn/netty/handler/codec/http/websocketx/WebSocketClientProtocolHandler.java b/netty-websocket-http1/src/main/java/com/jauntsdn/netty/handler/codec/http/websocketx/WebSocketClientProtocolHandler.java index ea31759..fdda21c 100644 --- a/netty-websocket-http1/src/main/java/com/jauntsdn/netty/handler/codec/http/websocketx/WebSocketClientProtocolHandler.java +++ b/netty-websocket-http1/src/main/java/com/jauntsdn/netty/handler/codec/http/websocketx/WebSocketClientProtocolHandler.java @@ -93,6 +93,11 @@ public ChannelFuture handshakeCompleted() { return completed; } + @Override + public boolean isSharable() { + return false; + } + @Override public void handlerAdded(ChannelHandlerContext ctx) { handshakeCompleted = ctx.newPromise(); diff --git a/netty-websocket-http1/src/main/java/com/jauntsdn/netty/handler/codec/http/websocketx/WebSocketServerProtocolHandler.java b/netty-websocket-http1/src/main/java/com/jauntsdn/netty/handler/codec/http/websocketx/WebSocketServerProtocolHandler.java index d8ae34a..49d0c76 100644 --- a/netty-websocket-http1/src/main/java/com/jauntsdn/netty/handler/codec/http/websocketx/WebSocketServerProtocolHandler.java +++ b/netty-websocket-http1/src/main/java/com/jauntsdn/netty/handler/codec/http/websocketx/WebSocketServerProtocolHandler.java @@ -87,6 +87,11 @@ public ChannelFuture handshakeCompleted() { return completed; } + @Override + public boolean isSharable() { + return false; + } + @Override public void handlerAdded(ChannelHandlerContext ctx) { handshakeCompleted = ctx.newPromise();