Author: markt Date: Fri Aug 5 16:29:58 2011 New Revision: 1154297 URL: http://svn.apache.org/viewvc?rev=1154297&view=rev Log: Fix https://issues.apache.org/bugzilla/show_bug.cgi?id=51610 Make lifecycle transitions more robust at handling unchecked exceptions
Modified: tomcat/trunk/java/org/apache/catalina/util/LifecycleBase.java tomcat/trunk/java/org/apache/catalina/util/LocalStrings.properties tomcat/trunk/webapps/docs/changelog.xml Modified: tomcat/trunk/java/org/apache/catalina/util/LifecycleBase.java URL: http://svn.apache.org/viewvc/tomcat/trunk/java/org/apache/catalina/util/LifecycleBase.java?rev=1154297&r1=1154296&r2=1154297&view=diff ============================================================================== --- tomcat/trunk/java/org/apache/catalina/util/LifecycleBase.java (original) +++ tomcat/trunk/java/org/apache/catalina/util/LifecycleBase.java Fri Aug 5 16:29:58 2011 @@ -23,6 +23,7 @@ import org.apache.catalina.LifecycleList import org.apache.catalina.LifecycleState; import org.apache.juli.logging.Log; import org.apache.juli.logging.LogFactory; +import org.apache.tomcat.util.ExceptionUtils; import org.apache.tomcat.util.res.StringManager; @@ -99,9 +100,11 @@ public abstract class LifecycleBase impl try { initInternal(); - } catch (LifecycleException e) { + } catch (Throwable t) { + ExceptionUtils.handleThrowable(t); setStateInternal(LifecycleState.FAILED, null, false); - throw e; + throw new LifecycleException( + sm.getString("lifecycleBase.initFail",toString()), t); } setStateInternal(LifecycleState.INITIALIZED, null, false); @@ -143,9 +146,11 @@ public abstract class LifecycleBase impl try { startInternal(); - } catch (LifecycleException e) { + } catch (Throwable t) { + ExceptionUtils.handleThrowable(t); setStateInternal(LifecycleState.FAILED, null, false); - throw e; + throw new LifecycleException( + sm.getString("lifecycleBase.startFail",toString()), t); } if (state.equals(LifecycleState.FAILED) || @@ -223,9 +228,11 @@ public abstract class LifecycleBase impl try { stopInternal(); - } catch (LifecycleException e) { + } catch (Throwable t) { + ExceptionUtils.handleThrowable(t); setStateInternal(LifecycleState.FAILED, null, false); - throw e; + throw new LifecycleException( + sm.getString("lifecycleBase.stopFail",toString()), t); } if (state.equals(LifecycleState.MUST_DESTROY)) { @@ -283,9 +290,11 @@ public abstract class LifecycleBase impl try { destroyInternal(); - } catch (LifecycleException e) { + } catch (Throwable t) { + ExceptionUtils.handleThrowable(t); setStateInternal(LifecycleState.FAILED, null, false); - throw e; + throw new LifecycleException( + sm.getString("lifecycleBase.destroyFail",toString()), t); } setStateInternal(LifecycleState.DESTROYED, null, false); Modified: tomcat/trunk/java/org/apache/catalina/util/LocalStrings.properties URL: http://svn.apache.org/viewvc/tomcat/trunk/java/org/apache/catalina/util/LocalStrings.properties?rev=1154297&r1=1154296&r2=1154297&view=diff ============================================================================== --- tomcat/trunk/java/org/apache/catalina/util/LocalStrings.properties (original) +++ tomcat/trunk/java/org/apache/catalina/util/LocalStrings.properties Fri Aug 5 16:29:58 2011 @@ -22,12 +22,16 @@ extensionValidator.web-application-manif extensionValidator.extension-not-found-error=ExtensionValidator[{0}][{1}]: Required extension [{2}] not found. extensionValidator.extension-validation-error=ExtensionValidator[{0}]: Failure to find [{1}] required extension(s). extensionValidator.failload=Failure loading extension [{0}] -lifecycleBase.initMBeanFail=Failed to register component [{0}] with MBean name [{1}] +lifecycleBase.alreadyDestroyed=The destroy() method was called on component [{0}] after destroy() had already been called. The second call will be ignored. lifecycleBase.alreadyStarted=The start() method was called on component [{0}] after start() had already been called. The second call will be ignored. lifecycleBase.alreadyStopped=The stop() method was called on component [{0}] after stop() had already been called. The second call will be ignored. -lifecycleBase.alreadyDestroyed=The destroy() method was called on component [{0}] after destroy() had already been called. The second call will be ignored. +lifecycleBase.destroyFail=Failed to destroy component [{0}] +lifecycleBase.initFail=Failed to initialize component [{0}] +lifecycleBase.initMBeanFail=Failed to register component [{0}] with MBean name [{1}] lifecycleBase.invalidTransition=An invalid Lifecycle transition was attempted ([{0}]) for component [{1}] in state [{2}] lifecycleBase.setState=Setting state for [{0}] to [{1}] +lifecycleBase.startFail=Failed to start component [{0}] +lifecycleBase.stopFail=Failed to stop component [{0}] lifecycleMBeanBase.registerFail=Failed to register object [{0}] with name [{0}] during component initialisation lifecycleMBeanBase.unregisterFail=Failed to unregister MBean with name [{0}] during component destruction lifecycleMBeanBase.unregisterNoServer=No MBean server was available to unregister the MBean [{0}] Modified: tomcat/trunk/webapps/docs/changelog.xml URL: http://svn.apache.org/viewvc/tomcat/trunk/webapps/docs/changelog.xml?rev=1154297&r1=1154296&r2=1154297&view=diff ============================================================================== --- tomcat/trunk/webapps/docs/changelog.xml (original) +++ tomcat/trunk/webapps/docs/changelog.xml Fri Aug 5 16:29:58 2011 @@ -130,6 +130,11 @@ in the same Context). (kkolinko) </fix> <fix> + <bug>51610</bug>: If an unchecked exception occurs during a lifecycle + transition (e.g. web application start) ensure that the component is + put into the failed state. (markt) + </fix> + <fix> <bug>51614</bug>: Avoid calling store.load() and session.expire() twice in PersistentManager when expiring sessions. (kfujino) </fix> --------------------------------------------------------------------- To unsubscribe, e-mail: dev-unsubscr...@tomcat.apache.org For additional commands, e-mail: dev-h...@tomcat.apache.org