diff --git a/jetty-deploy/src/main/java/org/eclipse/jetty/deploy/bindings/StandardUndeployer.java b/jetty-deploy/src/main/java/org/eclipse/jetty/deploy/bindings/StandardUndeployer.java index 969a6015467..3b093440e87 100644 --- a/jetty-deploy/src/main/java/org/eclipse/jetty/deploy/bindings/StandardUndeployer.java +++ b/jetty-deploy/src/main/java/org/eclipse/jetty/deploy/bindings/StandardUndeployer.java @@ -53,7 +53,7 @@ public class StandardUndeployer implements AppLifeCycle.Binding { Log.debug("Removing handler: " + child); coll.removeHandler(child); - ((ContextHandler)child).destroy(); + child.destroy(); Log.debug(String.format("After removal: %d (originally %d)",coll.getHandlers().length,originalCount)); } else if (child instanceof HandlerCollection) diff --git a/jetty-server/src/main/java/org/eclipse/jetty/server/handler/ContextHandler.java b/jetty-server/src/main/java/org/eclipse/jetty/server/handler/ContextHandler.java index 685b1878cd3..c238d8bc870 100644 --- a/jetty-server/src/main/java/org/eclipse/jetty/server/handler/ContextHandler.java +++ b/jetty-server/src/main/java/org/eclipse/jetty/server/handler/ContextHandler.java @@ -21,7 +21,6 @@ import java.net.URL; import java.net.URLClassLoader; import java.util.ArrayList; import java.util.Arrays; -import java.util.Collection; import java.util.Collections; import java.util.Enumeration; import java.util.EventListener; 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 26c7ff509c3..46a2e21b087 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 @@ -298,5 +298,16 @@ public class HandlerCollection extends AbstractHandlerContainer return list; } - + /* ------------------------------------------------------------ */ + @Override + public void destroy() + { + if (!isStopped()) + throw new IllegalStateException("!STOPPED"); + Handler[] children=getChildHandlers(); + setHandlers(null); + for (Handler child: children) + child.destroy(); + super.destroy(); + } } 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 1d0feacac23..7b3f631b457 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 @@ -163,6 +163,20 @@ public class HandlerWrapper extends AbstractHandlerContainer return null; } - + + /* ------------------------------------------------------------ */ + @Override + public void destroy() + { + if (!isStopped()) + throw new IllegalStateException("!STOPPED"); + Handler child=getHandler(); + if (child!=null) + { + setHandler(null); + child.destroy(); + } + super.destroy(); + } } 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 0b02b237f0f..106519015c2 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 @@ -155,7 +155,6 @@ public class HotSwapHandler extends AbstractHandlerContainer server.getContainer().update(this, null,_handler, "handler"); } - /* ------------------------------------------------------------ */ @Override protected Object expandChildren(Object list, Class byClass) @@ -163,5 +162,18 @@ public class HotSwapHandler extends AbstractHandlerContainer return expandHandler(_handler,list,byClass); } - + /* ------------------------------------------------------------ */ + @Override + public void destroy() + { + if (!isStopped()) + throw new IllegalStateException("!STOPPED"); + Handler child=getHandler(); + if (child!=null) + { + setHandler(null); + child.destroy(); + } + super.destroy(); + } }