Issue #1602 - LifeCycle FAILED fixes
+ AbstractLifeCycle.setFailed(Throwable) is now protected, so that the odd usages from WebAppContext.doStart() can be supported + The AbstractLifeCycle.doStart() now checks for state == FAILED
This commit is contained in:
parent
235cc149f3
commit
ce84ca35fb
|
@ -62,7 +62,7 @@ public abstract class AbstractLifeCycle implements LifeCycle
|
|||
{
|
||||
try
|
||||
{
|
||||
if (_state == __STARTED || _state == __STARTING)
|
||||
if (_state == __STARTED || _state == __STARTING || _state == __FAILED)
|
||||
return;
|
||||
setStarting();
|
||||
doStart();
|
||||
|
@ -206,7 +206,7 @@ public abstract class AbstractLifeCycle implements LifeCycle
|
|||
listener.lifeCycleStopped(this);
|
||||
}
|
||||
|
||||
private void setFailed(Throwable th)
|
||||
protected void setFailed(Throwable th)
|
||||
{
|
||||
_state = __FAILED;
|
||||
if (LOG.isDebugEnabled())
|
||||
|
|
|
@ -554,6 +554,7 @@ public class WebAppContext extends ServletContextHandler implements WebAppClassL
|
|||
LOG.warn("Failed startup of context "+this, t);
|
||||
_unavailableException=t;
|
||||
setAvailable(false);
|
||||
setFailed(t);
|
||||
if (isThrowUnavailableOnStartupException())
|
||||
throw t;
|
||||
}
|
||||
|
|
|
@ -18,6 +18,7 @@
|
|||
|
||||
package org.eclipse.jetty.test;
|
||||
|
||||
import static org.hamcrest.Matchers.instanceOf;
|
||||
import static org.hamcrest.Matchers.notNullValue;
|
||||
import static org.hamcrest.Matchers.nullValue;
|
||||
import static org.hamcrest.core.Is.is;
|
||||
|
@ -52,6 +53,7 @@ public class DeploymentErrorTest
|
|||
{
|
||||
private static Server server;
|
||||
private static DeploymentManager deploymentManager;
|
||||
private static ContextHandlerCollection contexts;
|
||||
|
||||
@BeforeClass
|
||||
public static void setUpServer()
|
||||
|
@ -63,12 +65,8 @@ public class DeploymentErrorTest
|
|||
connector.setPort(0);
|
||||
server.addConnector(connector);
|
||||
|
||||
// Empty handler collections
|
||||
ContextHandlerCollection contexts = new ContextHandlerCollection();
|
||||
HandlerCollection handlers = new HandlerCollection();
|
||||
handlers.setHandlers(new Handler[]
|
||||
{ contexts, new DefaultHandler() });
|
||||
server.setHandler(handlers);
|
||||
// Empty contexts collections
|
||||
contexts = new ContextHandlerCollection();
|
||||
|
||||
// Deployment Manager
|
||||
deploymentManager = new DeploymentManager();
|
||||
|
@ -83,6 +81,12 @@ public class DeploymentErrorTest
|
|||
deploymentManager.addAppProvider(appProvider);
|
||||
server.addBean(deploymentManager);
|
||||
|
||||
// Server handlers
|
||||
HandlerCollection handlers = new HandlerCollection();
|
||||
handlers.setHandlers(new Handler[]
|
||||
{contexts, new DefaultHandler() });
|
||||
server.setHandler(handlers);
|
||||
|
||||
// Setup Configurations
|
||||
Configuration.ClassList classlist = Configuration.ClassList
|
||||
.setServerDefault(server);
|
||||
|
@ -164,6 +168,21 @@ public class DeploymentErrorTest
|
|||
assertThat("trackedConfig.postConfigureCount", trackedConfiguration.postConfigureCounts.get(contextPath), nullValue());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testContextHandlerCollection()
|
||||
{
|
||||
Handler handlers[] = contexts.getHandlers();
|
||||
assertThat("ContextHandlerCollection.Handlers.length", handlers.length, is(2));
|
||||
|
||||
// Verify that both handlers are unavailable
|
||||
for(Handler handler: handlers)
|
||||
{
|
||||
assertThat("Handler", handler, instanceOf(ContextHandler.class));
|
||||
ContextHandler contextHandler = (ContextHandler) handler;
|
||||
assertThat("ContextHandler.isAvailable", contextHandler.isAvailable(), is(false));
|
||||
}
|
||||
}
|
||||
|
||||
private App findApp(String contextPath, List<App> apps)
|
||||
{
|
||||
for (App app : apps)
|
||||
|
|
Loading…
Reference in New Issue