From 0c6c11d79d55d21ee1b838886cb55f706038d168 Mon Sep 17 00:00:00 2001 From: Greg Wilkins Date: Fri, 2 Sep 2016 12:14:23 +1000 Subject: [PATCH] Issue #897 If a request is not handled within the scope of the GzipHandler, the gzip interceptor is removed so it cannot be used by any subsequent handlers. If the request is handled, it is left in place to be used by any async handling. --- .../jetty/server/handler/gzip/GzipHandler.java | 18 ++++++++++++++---- 1 file changed, 14 insertions(+), 4 deletions(-) diff --git a/jetty-server/src/main/java/org/eclipse/jetty/server/handler/gzip/GzipHandler.java b/jetty-server/src/main/java/org/eclipse/jetty/server/handler/gzip/GzipHandler.java index fe650d4a133..4f12f8a8997 100644 --- a/jetty-server/src/main/java/org/eclipse/jetty/server/handler/gzip/GzipHandler.java +++ b/jetty-server/src/main/java/org/eclipse/jetty/server/handler/gzip/GzipHandler.java @@ -454,11 +454,21 @@ public class GzipHandler extends HandlerWrapper implements GzipFactory } } - // install interceptor and handle - out.setInterceptor(new GzipHttpOutputInterceptor(this,getVaryField(),baseRequest.getHttpChannel(),out.getInterceptor(),isSyncFlush())); + HttpOutput.Interceptor orig_interceptor = out.getInterceptor(); + try + { + // install interceptor and handle + out.setInterceptor(new GzipHttpOutputInterceptor(this,getVaryField(),baseRequest.getHttpChannel(),orig_interceptor,isSyncFlush())); - if (_handler!=null) - _handler.handle(target,baseRequest, request, response); + if (_handler!=null) + _handler.handle(target,baseRequest, request, response); + } + finally + { + // reset interceptor if request not handled + if (!baseRequest.isHandled() && !baseRequest.isAsyncStarted()) + out.setInterceptor(orig_interceptor); + } } /* ------------------------------------------------------------ */