Merge pull request #1238 from raimohanska/jetty-9.4.x

Fix NPE in ContextHandler.isShutdown
This commit is contained in:
Jan Bartel 2017-03-30 09:38:25 +11:00 committed by GitHub
commit 9732e3a985
2 changed files with 8 additions and 10 deletions

View File

@ -206,7 +206,7 @@ public class ContextHandler extends ScopedHandler implements Attributes, Gracefu
private final CopyOnWriteArrayList<AliasCheck> _aliasChecks = new CopyOnWriteArrayList<ContextHandler.AliasCheck>();
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;
}
/* ------------------------------------------------------------ */

View File

@ -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
{