From cd420d7db5679aa80b5a2aad1ea51ef62e842b4c Mon Sep 17 00:00:00 2001 From: Greg Wilkins Date: Thu, 11 Jun 2015 12:39:03 +1000 Subject: [PATCH] 465118 Fixed GzipHandler handling of multiple closes --- .../src/main/java/org/eclipse/jetty/embedded/FileServer.java | 5 ++++- .../src/main/java/org/eclipse/jetty/server/HttpOutput.java | 1 + .../jetty/server/handler/gzip/GzipHttpOutputInterceptor.java | 3 +++ 3 files changed, 8 insertions(+), 1 deletion(-) diff --git a/examples/embedded/src/main/java/org/eclipse/jetty/embedded/FileServer.java b/examples/embedded/src/main/java/org/eclipse/jetty/embedded/FileServer.java index 18a90bf56f9..fc0b03a168e 100644 --- a/examples/embedded/src/main/java/org/eclipse/jetty/embedded/FileServer.java +++ b/examples/embedded/src/main/java/org/eclipse/jetty/embedded/FileServer.java @@ -23,6 +23,7 @@ import org.eclipse.jetty.server.Server; import org.eclipse.jetty.server.handler.DefaultHandler; import org.eclipse.jetty.server.handler.HandlerList; import org.eclipse.jetty.server.handler.ResourceHandler; +import org.eclipse.jetty.server.handler.gzip.GzipHandler; /** * Simple Jetty FileServer. @@ -47,9 +48,11 @@ public class FileServer resource_handler.setResourceBase("."); // Add the ResourceHandler to the server. + GzipHandler gzip = new GzipHandler(); + server.setHandler(gzip); HandlerList handlers = new HandlerList(); handlers.setHandlers(new Handler[] { resource_handler, new DefaultHandler() }); - server.setHandler(handlers); + gzip.setHandler(handlers); // Start things up! By using the server.join() the server thread will join with the current thread. // See "http://docs.oracle.com/javase/1.5.0/docs/api/java/lang/Thread.html#join()" for more details. diff --git a/jetty-server/src/main/java/org/eclipse/jetty/server/HttpOutput.java b/jetty-server/src/main/java/org/eclipse/jetty/server/HttpOutput.java index f6b08cee798..940ea3f7fcd 100644 --- a/jetty-server/src/main/java/org/eclipse/jetty/server/HttpOutput.java +++ b/jetty-server/src/main/java/org/eclipse/jetty/server/HttpOutput.java @@ -586,6 +586,7 @@ public class HttpOutput extends ServletOutputStream implements Runnable public void sendContent(ByteBuffer content) throws IOException { write(content, true); + closed(); } /** diff --git a/jetty-server/src/main/java/org/eclipse/jetty/server/handler/gzip/GzipHttpOutputInterceptor.java b/jetty-server/src/main/java/org/eclipse/jetty/server/handler/gzip/GzipHttpOutputInterceptor.java index dacc476447a..41ba3b9c65c 100644 --- a/jetty-server/src/main/java/org/eclipse/jetty/server/handler/gzip/GzipHttpOutputInterceptor.java +++ b/jetty-server/src/main/java/org/eclipse/jetty/server/handler/gzip/GzipHttpOutputInterceptor.java @@ -287,6 +287,9 @@ public class GzipHttpOutputInterceptor implements HttpOutput.Interceptor @Override protected Action process() throws Exception { + if (_deflater==null) + return Action.SUCCEEDED; + if (_deflater.needsInput()) { if (BufferUtil.isEmpty(_content))