Skip to content

Commit

Permalink
Simplify Deflate* implementations by using EmbeddedChannel.finishAndR…
Browse files Browse the repository at this point in the history
…eleaseAll() (#9808)

Motivation:

We can simplify the code by just using finishAndReleaseAll()

Modifications:

Remove some code and simplify

Result:

Cleaner code
  • Loading branch information
normanmaurer committed Nov 27, 2019
1 parent 621af5c commit f2596fd
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 20 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -150,16 +150,7 @@ private ByteBuf decompressContent(ChannelHandlerContext ctx, WebSocketFrame msg)
private void cleanup() {
if (decoder != null) {
// Clean-up the previous encoder if not cleaned up correctly.
if (decoder.finish()) {
for (;;) {
ByteBuf buf = decoder.readOutbound();
if (buf == null) {
break;
}
// Release the buffer
buf.release();
}
}
decoder.finishAndReleaseAll();
decoder = null;
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -158,16 +158,7 @@ private ByteBuf compressContent(ChannelHandlerContext ctx, WebSocketFrame msg) {
private void cleanup() {
if (encoder != null) {
// Clean-up the previous encoder if not cleaned up correctly.
if (encoder.finish()) {
for (;;) {
ByteBuf buf = encoder.readOutbound();
if (buf == null) {
break;
}
// Release the buffer
buf.release();
}
}
encoder.finishAndReleaseAll();
encoder = null;
}
}
Expand Down

0 comments on commit f2596fd

Please sign in to comment.