From aaef54951f70ffdde706d8610d63777a033bac34 Mon Sep 17 00:00:00 2001 From: Dmitriy Dumanskiy Date: Mon, 29 Mar 2021 10:01:38 +0300 Subject: [PATCH] remove unnecessary check in WebSocketFrameDecoder (#11113) Motivation: There are some redundant checks and so these can be removed Modifications: - First check frameOpcode != OPCODE_PING is removed because the code executed int the branch where frameOpcode <= 7, while OPCODE_PING is 9. - Second check frameOpcode != OPCODE_PING is removed because its checked before. Result: Code cleanup --- .../codec/http/websocketx/WebSocket08FrameDecoder.java | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/codec-http/src/main/java/io/netty/handler/codec/http/websocketx/WebSocket08FrameDecoder.java b/codec-http/src/main/java/io/netty/handler/codec/http/websocketx/WebSocket08FrameDecoder.java index 1d600c1131..e2b9b31ac9 100644 --- a/codec-http/src/main/java/io/netty/handler/codec/http/websocketx/WebSocket08FrameDecoder.java +++ b/codec-http/src/main/java/io/netty/handler/codec/http/websocketx/WebSocket08FrameDecoder.java @@ -246,7 +246,7 @@ public class WebSocket08FrameDecoder extends ByteToMessageDecoder } // check opcode vs message fragmentation state 2/2 - if (fragmentedFramesCount != 0 && frameOpcode != OPCODE_CONT && frameOpcode != OPCODE_PING) { + if (fragmentedFramesCount != 0 && frameOpcode != OPCODE_CONT) { protocolViolation(ctx, in, "received non-continuation data frame while inside fragmented message"); return; @@ -347,9 +347,7 @@ public class WebSocket08FrameDecoder extends ByteToMessageDecoder if (frameFinalFlag) { // Final frame of the sequence. Apparently ping frames are // allowed in the middle of a fragmented message - if (frameOpcode != OPCODE_PING) { - fragmentedFramesCount = 0; - } + fragmentedFramesCount = 0; } else { // Increment counter fragmentedFramesCount++;