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
This commit is contained in:
Dmitriy Dumanskiy 2021-03-29 10:01:38 +03:00 committed by GitHub
parent b05fdf3ff8
commit aaef54951f
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -246,7 +246,7 @@ public class WebSocket08FrameDecoder extends ByteToMessageDecoder
} }
// check opcode vs message fragmentation state 2/2 // 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, protocolViolation(ctx, in,
"received non-continuation data frame while inside fragmented message"); "received non-continuation data frame while inside fragmented message");
return; return;
@ -347,9 +347,7 @@ public class WebSocket08FrameDecoder extends ByteToMessageDecoder
if (frameFinalFlag) { if (frameFinalFlag) {
// Final frame of the sequence. Apparently ping frames are // Final frame of the sequence. Apparently ping frames are
// allowed in the middle of a fragmented message // allowed in the middle of a fragmented message
if (frameOpcode != OPCODE_PING) {
fragmentedFramesCount = 0; fragmentedFramesCount = 0;
}
} else { } else {
// Increment counter // Increment counter
fragmentedFramesCount++; fragmentedFramesCount++;