From 4c99beeaba485ea4141ba903257d1c36c9d4ba69 Mon Sep 17 00:00:00 2001 From: Greg Wilkins Date: Thu, 10 Mar 2016 12:21:06 +1100 Subject: [PATCH] Issue #413 HotSwapHandler null handlers Fixed #413 --- .../jetty/server/handler/HotSwapHandler.java | 22 +++++++++++-------- 1 file changed, 13 insertions(+), 9 deletions(-) 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 f1854501774..6dff88c98c7 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 @@ -62,8 +62,10 @@ public class HotSwapHandler extends AbstractHandlerContainer @Override public Handler[] getHandlers() { - return new Handler[] - { _handler }; + Handler handler=_handler; + if (handler==null) + return new Handler[0]; + return new Handler[] { handler }; } /* ------------------------------------------------------------ */ @@ -73,14 +75,13 @@ public class HotSwapHandler extends AbstractHandlerContainer */ public void setHandler(Handler handler) { - if (handler == null) - throw new IllegalArgumentException("Parameter handler is null."); try { + Server server = getServer(); + if (handler!=null) + handler.setServer(server); updateBean(_handler,handler,true); _handler=handler; - Server server = getServer(); - handler.setServer(server); } catch (Exception e) @@ -116,9 +117,10 @@ public class HotSwapHandler extends AbstractHandlerContainer @Override public void handle(String target, Request baseRequest, HttpServletRequest request, HttpServletResponse response) throws IOException, ServletException { - if (_handler != null && isStarted()) + Handler handler=_handler; + if (handler != null && isStarted() && handler.isStarted()) { - _handler.handle(target,baseRequest,request,response); + handler.handle(target,baseRequest,request,response); } } @@ -126,7 +128,9 @@ public class HotSwapHandler extends AbstractHandlerContainer @Override protected void expandChildren(List list, Class byClass) { - expandHandler(_handler,list,byClass); + Handler handler=_handler; + if (handler!=null) + expandHandler(handler,list,byClass); } /* ------------------------------------------------------------ */