Simplify Deflate* implementations by using EmbeddedChannel.finishAndReleaseAll() (#9808)

Motivation:

We can simplify the code by just using finishAndReleaseAll()

Modifications:

Remove some code and simplify

Result:

Cleaner code
This commit is contained in:
Norman Maurer 2019-11-27 06:54:55 +01:00 committed by GitHub
parent 5f5776c3e6
commit 2886bd6677
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 2 additions and 20 deletions

View File

@ -150,16 +150,7 @@ abstract class DeflateDecoder extends WebSocketExtensionDecoder {
private void cleanup() { private void cleanup() {
if (decoder != null) { if (decoder != null) {
// Clean-up the previous encoder if not cleaned up correctly. // Clean-up the previous encoder if not cleaned up correctly.
if (decoder.finish()) { decoder.finishAndReleaseAll();
for (;;) {
ByteBuf buf = decoder.readOutbound();
if (buf == null) {
break;
}
// Release the buffer
buf.release();
}
}
decoder = null; decoder = null;
} }
} }

View File

@ -158,16 +158,7 @@ abstract class DeflateEncoder extends WebSocketExtensionEncoder {
private void cleanup() { private void cleanup() {
if (encoder != null) { if (encoder != null) {
// Clean-up the previous encoder if not cleaned up correctly. // Clean-up the previous encoder if not cleaned up correctly.
if (encoder.finish()) { encoder.finishAndReleaseAll();
for (;;) {
ByteBuf buf = encoder.readOutbound();
if (buf == null) {
break;
}
// Release the buffer
buf.release();
}
}
encoder = null; encoder = null;
} }
} }