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 d112b3bdc6e..25cb06553bf 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 @@ -206,7 +206,7 @@ public class ContextHandler extends ScopedHandler implements Attributes, Gracefu private final CopyOnWriteArrayList _aliasChecks = new CopyOnWriteArrayList(); public enum Availability { UNAVAILABLE,STARTING,AVAILABLE,SHUTDOWN,}; - private volatile Availability _availability; + private volatile Availability _availability = Availability.UNAVAILABLE; /* ------------------------------------------------------------ */ public ContextHandler() @@ -684,18 +684,12 @@ public class ContextHandler extends ScopedHandler implements Attributes, Gracefu /* ------------------------------------------------------------ */ /** - * @return true if this context is accepting new requests + * @return true if this context is shutting down */ @ManagedAttribute("true for graceful shutdown, which allows existing requests to complete") public boolean isShutdown() { - switch(_availability) - { - case SHUTDOWN: - return true; - default: - return false; - } + return _availability == Availability.SHUTDOWN; } /* ------------------------------------------------------------ */ diff --git a/jetty-server/src/test/java/org/eclipse/jetty/server/handler/ContextHandlerTest.java b/jetty-server/src/test/java/org/eclipse/jetty/server/handler/ContextHandlerTest.java index 4f56edbec31..b5e9b79117d 100644 --- a/jetty-server/src/test/java/org/eclipse/jetty/server/handler/ContextHandlerTest.java +++ b/jetty-server/src/test/java/org/eclipse/jetty/server/handler/ContextHandlerTest.java @@ -447,7 +447,11 @@ public class ContextHandlerTest Assert.assertTrue(handler.isProtectedTarget("/ABC/7777")); } - + @Test + public void testIsShutdown() { + ContextHandler handler = new ContextHandler(); + Assert.assertEquals(false, handler.isShutdown()); + } private void checkResourcePathsForExampleWebApp(String root) throws IOException {