From 1d894a15160cba0a835b2b33cd6a3c96773b1eca Mon Sep 17 00:00:00 2001 From: Mark Thomas Date: Wed, 20 Jan 2016 10:28:37 +0000 Subject: [PATCH] Further fix to regression in r1725599 Trigger a call to stop() if a component puts itself into the FAILED state during start(). git-svn-id: https://svn.apache.org/repos/asf/tomcat/trunk@1725694 13f79535-47bb-0310-9956-ffa450edef68 --- java/org/apache/catalina/util/LifecycleBase.java | 16 +++++++++++----- 1 file changed, 11 insertions(+), 5 deletions(-) diff --git a/java/org/apache/catalina/util/LifecycleBase.java b/java/org/apache/catalina/util/LifecycleBase.java index 553cec089651..e1bc7e94695d 100644 --- a/java/org/apache/catalina/util/LifecycleBase.java +++ b/java/org/apache/catalina/util/LifecycleBase.java @@ -151,18 +151,24 @@ public final synchronized void start() throws LifecycleException { try { startInternal(); } catch (Throwable t) { + // This is an 'uncontrolled' failure so put the component into the + // FAILED state and throw an exception. ExceptionUtils.handleThrowable(t); setStateInternal(LifecycleState.FAILED, null, false); throw new LifecycleException(sm.getString("lifecycleBase.startFail", toString()), t); } - // Shouldn't be necessary but acts as a check that sub-classes are - // doing what they are supposed to. - if (!state.equals(LifecycleState.STARTING)) { + if (state.equals(LifecycleState.FAILED)) { + // This is a 'controlled' failure. The component put itself into the + // FAILED state so call stop() to complete the clean-up. + stop(); + } else if (!state.equals(LifecycleState.STARTING)) { + // Shouldn't be necessary but acts as a check that sub-classes are + // doing what they are supposed to. invalidTransition(Lifecycle.AFTER_START_EVENT); + } else { + setStateInternal(LifecycleState.STARTED, null, false); } - - setStateInternal(LifecycleState.STARTED, null, false); }