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
parent 621af5ce27
commit f2596fd993
2 changed files with 2 additions and 20 deletions

View File

@ -150,16 +150,7 @@ abstract class DeflateDecoder extends WebSocketExtensionDecoder {
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;
}
}

View File

@ -158,16 +158,7 @@ abstract class DeflateEncoder extends WebSocketExtensionEncoder {
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;
}
}