Issue #1602 - Requested fixes to StandardStarter and AbstractLifeCycle

This commit is contained in:
Joakim Erdfelt 2018-01-11 10:00:39 -06:00
parent ce84ca35fb
commit 4ba0277c37
3 changed files with 15 additions and 9 deletions

View File

@ -22,6 +22,7 @@ import org.eclipse.jetty.deploy.App;
import org.eclipse.jetty.deploy.AppLifeCycle;
import org.eclipse.jetty.deploy.graph.Node;
import org.eclipse.jetty.server.handler.ContextHandler;
import org.eclipse.jetty.server.handler.ContextHandlerCollection;
public class StandardStarter implements AppLifeCycle.Binding
{
@ -35,12 +36,17 @@ public class StandardStarter implements AppLifeCycle.Binding
@Override
public void processBinding(Node node, App app) throws Exception
{
ContextHandlerCollection contexts = app.getDeploymentManager().getContexts();
ContextHandler handler = app.getContextHandler();
// start the handler
handler.start();
// After starting let the context manage state
app.getDeploymentManager().getContexts().manage(handler);
if (contexts.isRunning() && !handler.isRunning())
{
// start the handler manually
handler.start();
// After starting let the context manage state
contexts.manage(handler);
}
}
}

View File

@ -62,7 +62,7 @@ public abstract class AbstractLifeCycle implements LifeCycle
{
try
{
if (_state == __STARTED || _state == __STARTING || _state == __FAILED)
if (_state == __STARTED || _state == __STARTING)
return;
setStarting();
doStart();

View File

@ -553,8 +553,8 @@ public class WebAppContext extends ServletContextHandler implements WebAppClassL
// start up of the webapp context failed, make sure it is not started
LOG.warn("Failed startup of context "+this, t);
_unavailableException=t;
setAvailable(false);
setFailed(t);
setAvailable(false); // webapp cannot be accessed
setFailed(t); // be a proper Jetty LifeCycle participant and notify listeners of failure
if (isThrowUnavailableOnStartupException())
throw t;
}