diff --git a/jetty-client/src/main/java/org/eclipse/jetty/client/GZIPContentDecoder.java b/jetty-client/src/main/java/org/eclipse/jetty/client/GZIPContentDecoder.java index 8bae3b8a993..2ee10aa9a48 100644 --- a/jetty-client/src/main/java/org/eclipse/jetty/client/GZIPContentDecoder.java +++ b/jetty-client/src/main/java/org/eclipse/jetty/client/GZIPContentDecoder.java @@ -25,11 +25,12 @@ import java.util.zip.Inflater; import java.util.zip.ZipException; import org.eclipse.jetty.util.BufferUtil; +import org.eclipse.jetty.util.component.Destroyable; /** * {@link ContentDecoder} for the "gzip" encoding. */ -public class GZIPContentDecoder implements ContentDecoder +public class GZIPContentDecoder implements ContentDecoder, Destroyable { private final Inflater inflater = new Inflater(true); private final byte[] bytes; @@ -322,6 +323,12 @@ public class GZIPContentDecoder implements ContentDecoder flags = 0; } + @Override + public void destroy() + { + inflater.end(); + } + protected boolean isFinished() { return state == State.INITIAL; diff --git a/jetty-client/src/main/java/org/eclipse/jetty/client/HttpReceiver.java b/jetty-client/src/main/java/org/eclipse/jetty/client/HttpReceiver.java index 02a6825b32b..bacab1aa2f8 100644 --- a/jetty-client/src/main/java/org/eclipse/jetty/client/HttpReceiver.java +++ b/jetty-client/src/main/java/org/eclipse/jetty/client/HttpReceiver.java @@ -37,6 +37,7 @@ import org.eclipse.jetty.http.HttpStatus; import org.eclipse.jetty.util.BufferUtil; import org.eclipse.jetty.util.Callback; import org.eclipse.jetty.util.CountingCallback; +import org.eclipse.jetty.util.component.Destroyable; import org.eclipse.jetty.util.log.Log; import org.eclipse.jetty.util.log.Logger; @@ -465,6 +466,7 @@ public abstract class HttpReceiver */ protected void reset() { + destroyDecoder(decoder); decoder = null; } @@ -477,9 +479,18 @@ public abstract class HttpReceiver */ protected void dispose() { + destroyDecoder(decoder); decoder = null; } + private static void destroyDecoder(ContentDecoder decoder) + { + if (decoder instanceof Destroyable) + { + ((Destroyable)decoder).destroy(); + } + } + public boolean abort(HttpExchange exchange, Throwable failure) { // Update the state to avoid more response processing.