416577 enhanced shutdown handler to send shutdown at startup

This commit is contained in:
Greg Wilkins 2013-09-19 12:28:07 +10:00
parent ba5a709245
commit 3acda280a8
3 changed files with 8 additions and 4 deletions

View File

@ -55,6 +55,8 @@ public abstract class AbstractHandler extends ContainerLifeCycle implements Hand
protected void doStart() throws Exception
{
LOG.debug("starting {}",this);
if (_server==null)
LOG.warn("No Server set for {}",this);
super.doStart();
}

View File

@ -189,6 +189,7 @@ public class ShutdownHandler extends HandlerWrapper
LOG.info("Shutting down by request from " + getRemoteAddr(request));
final Server server=getServer();
new Thread()
{
@Override
@ -196,7 +197,7 @@ public class ShutdownHandler extends HandlerWrapper
{
try
{
shutdownServer();
shutdownServer(server);
}
catch (InterruptedException e)
{
@ -227,9 +228,9 @@ public class ShutdownHandler extends HandlerWrapper
return _shutdownToken.equals(tok);
}
private void shutdownServer() throws Exception
private void shutdownServer(Server server) throws Exception
{
getServer().stop();
server.stop();
if (_exitJvm)
{

View File

@ -51,8 +51,9 @@ public class ShutdownHandlerTest
public void startServer() throws Exception
{
MockitoAnnotations.initMocks(this);
shutdownHandler = new ShutdownHandler(shutdownToken);
server.setHandler(shutdownHandler);
server.start();
shutdownHandler = new ShutdownHandler(server,shutdownToken);
}
@Test