Skip to content

Commit

Permalink
Drop empty packets
Browse files Browse the repository at this point in the history
  • Loading branch information
RaphiMC committed Feb 8, 2024
1 parent 721a328 commit c624ce8
Showing 1 changed file with 8 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,10 @@ public void handlerRemoved(ChannelHandlerContext ctx) throws Exception {

@Override
protected void encode(ChannelHandlerContext ctx, ByteBuf in, ByteBuf out) throws Exception {
if (!in.isReadable()) {
return;
}

final int inputSize = in.readableBytes();
final CompressionAlgorithm compressionAlgorithm = this.protocolCompression.getCompressionAlgorithmForSize(inputSize);
if (compressionAlgorithm instanceof NoopCompression) {
Expand All @@ -66,6 +70,10 @@ protected void encode(ChannelHandlerContext ctx, ByteBuf in, ByteBuf out) throws

@Override
protected void decode(ChannelHandlerContext ctx, ByteBuf in, List<Object> out) throws Exception {
if (!in.isReadable()) {
return;
}

final int algorithm = in.readUnsignedByte();
final CompressionAlgorithm compressionAlgorithm = this.protocolCompression.getAlgorithmById(algorithm);
if (compressionAlgorithm instanceof NoopCompression) {
Expand Down

0 comments on commit c624ce8

Please sign in to comment.