diff --git a/examples/embedded/src/main/java/org/eclipse/jetty/embedded/ManyHandlers.java b/examples/embedded/src/main/java/org/eclipse/jetty/embedded/ManyHandlers.java index 2bc37cb97e7..76061f92bad 100644 --- a/examples/embedded/src/main/java/org/eclipse/jetty/embedded/ManyHandlers.java +++ b/examples/embedded/src/main/java/org/eclipse/jetty/embedded/ManyHandlers.java @@ -36,6 +36,7 @@ import org.eclipse.jetty.server.handler.HandlerCollection; import org.eclipse.jetty.server.handler.HandlerList; import org.eclipse.jetty.server.handler.HandlerWrapper; import org.eclipse.jetty.server.handler.RequestLogHandler; +import org.eclipse.jetty.server.handler.gzip.GzipHandler; import org.eclipse.jetty.util.ajax.JSON; /** @@ -127,7 +128,7 @@ public class ManyHandlers // link them all together wrapper.setHandler(hello); - list.setHandlers(new Handler[] { param, wrapper, dft }); + list.setHandlers(new Handler[] { param, new GzipHandler(), dft }); handlers.setHandlers(new Handler[] { list, requestLog }); // Handler tree looks like the following diff --git a/jetty-server/src/main/java/org/eclipse/jetty/server/handler/AbstractHandlerContainer.java b/jetty-server/src/main/java/org/eclipse/jetty/server/handler/AbstractHandlerContainer.java index 45246726d71..4db474df125 100644 --- a/jetty-server/src/main/java/org/eclipse/jetty/server/handler/AbstractHandlerContainer.java +++ b/jetty-server/src/main/java/org/eclipse/jetty/server/handler/AbstractHandlerContainer.java @@ -25,6 +25,7 @@ import java.util.List; import org.eclipse.jetty.server.Handler; import org.eclipse.jetty.server.HandlerContainer; +import org.eclipse.jetty.server.Server; /* ------------------------------------------------------------ */ @@ -117,4 +118,21 @@ public abstract class AbstractHandlerContainer extends AbstractHandler implement } return null; } + + /* ------------------------------------------------------------ */ + @Override + public void setServer(Server server) + { + if (server==getServer()) + return; + + if (isStarted()) + throw new IllegalStateException(STARTED); + + super.setServer(server); + Handler[] handlers=getHandlers(); + if (handlers!=null) + for (Handler h : handlers) + h.setServer(server); + } } diff --git a/jetty-server/src/main/java/org/eclipse/jetty/server/handler/HandlerCollection.java b/jetty-server/src/main/java/org/eclipse/jetty/server/handler/HandlerCollection.java index 4f39869c307..f799b3a4f85 100644 --- a/jetty-server/src/main/java/org/eclipse/jetty/server/handler/HandlerCollection.java +++ b/jetty-server/src/main/java/org/eclipse/jetty/server/handler/HandlerCollection.java @@ -134,17 +134,6 @@ public class HandlerCollection extends AbstractHandlerContainer } } - /* ------------------------------------------------------------ */ - @Override - public void setServer(Server server) - { - super.setServer(server); - Handler[] handlers=getHandlers(); - if (handlers!=null) - for (Handler h : handlers) - h.setServer(server); - } - /* ------------------------------------------------------------ */ /* Add a handler. * This implementation adds the passed handler to the end of the existing collection of handlers. diff --git a/jetty-server/src/main/java/org/eclipse/jetty/server/handler/HandlerWrapper.java b/jetty-server/src/main/java/org/eclipse/jetty/server/handler/HandlerWrapper.java index 3e1d0c769a8..b5c966f764c 100644 --- a/jetty-server/src/main/java/org/eclipse/jetty/server/handler/HandlerWrapper.java +++ b/jetty-server/src/main/java/org/eclipse/jetty/server/handler/HandlerWrapper.java @@ -120,23 +120,6 @@ public class HandlerWrapper extends AbstractHandlerContainer } - /* ------------------------------------------------------------ */ - @Override - public void setServer(Server server) - { - if (server==getServer()) - return; - - if (isStarted()) - throw new IllegalStateException(STARTED); - - super.setServer(server); - Handler h=getHandler(); - if (h!=null) - h.setServer(server); - } - - /* ------------------------------------------------------------ */ @Override protected void expandChildren(List list, Class byClass) diff --git a/jetty-server/src/main/java/org/eclipse/jetty/server/handler/HotSwapHandler.java b/jetty-server/src/main/java/org/eclipse/jetty/server/handler/HotSwapHandler.java index 68eaad1b7e0..de87d977ef4 100644 --- a/jetty-server/src/main/java/org/eclipse/jetty/server/handler/HotSwapHandler.java +++ b/jetty-server/src/main/java/org/eclipse/jetty/server/handler/HotSwapHandler.java @@ -122,20 +122,6 @@ public class HotSwapHandler extends AbstractHandlerContainer } } - /* ------------------------------------------------------------ */ - @Override - public void setServer(Server server) - { - if (isRunning()) - throw new IllegalStateException(RUNNING); - - super.setServer(server); - - Handler h = getHandler(); - if (h != null) - h.setServer(server); - } - /* ------------------------------------------------------------ */ @Override protected void expandChildren(List list, Class byClass) 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 dd4c8805dff..e2aac872dba 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 @@ -380,7 +380,8 @@ public class GzipHandler extends HandlerWrapper implements GzipFactory // install interceptor and handle out.setInterceptor(new GzipHttpOutputInterceptor(this,_vary,baseRequest.getHttpChannel(),out.getInterceptor())); - _handler.handle(target,baseRequest, request, response); + if (_handler!=null) + _handler.handle(target,baseRequest, request, response); }