Re-fix https://issues.apache.org/bugzilla/show_bug.cgi?id=49372
authormarkt <markt@13f79535-47bb-0310-9956-ffa450edef68>
Tue, 4 Jan 2011 17:57:16 +0000 (17:57 +0000)
committermarkt <markt@13f79535-47bb-0310-9956-ffa450edef68>
Tue, 4 Jan 2011 17:57:16 +0000 (17:57 +0000)
Don't throw an LifecycleException for an invalid transition if a connector fails to start.

git-svn-id: https://svn.apache.org/repos/asf/tomcat/trunk@1055121 13f79535-47bb-0310-9956-ffa450edef68

java/org/apache/catalina/core/StandardService.java
java/org/apache/catalina/util/LifecycleBase.java
webapps/docs/changelog.xml

index cbada81..216a7f8 100644 (file)
@@ -453,7 +453,10 @@ public class StandardService extends LifecycleMBeanBase implements Service {
         synchronized (connectors) {
             for (Connector connector: connectors) {
                 try {
-                    connector.start();
+                    // If it has already failed, don't try and start it
+                    if (connector.getState() != LifecycleState.FAILED) {
+                        connector.start();
+                    }
                 } catch (Exception e) {
                     log.error(sm.getString(
                             "standardService.connector.startFailed",
index b64492e..bfe725d 100644 (file)
@@ -97,7 +97,12 @@ public abstract class LifecycleBase implements Lifecycle {
         }
         setState(LifecycleState.INITIALIZING);
 
-        initInternal();
+        try {
+            initInternal();
+        } catch (LifecycleException e) {
+            setState(LifecycleState.FAILED);
+            throw e;
+        }
 
         setState(LifecycleState.INITIALIZED);
     }
@@ -213,7 +218,12 @@ public abstract class LifecycleBase implements Lifecycle {
         
         setState(LifecycleState.STOPPING_PREP);
 
-        stopInternal();
+        try {
+            stopInternal();
+        } catch (LifecycleException e) {
+            setState(LifecycleState.FAILED);
+            throw e;
+        }
 
         if (state.equals(LifecycleState.MUST_DESTROY)) {
             // Complete stop process first
@@ -221,8 +231,8 @@ public abstract class LifecycleBase implements Lifecycle {
 
             destroy();
         } else {
-            // Shouldn't be necessary but acts as a check that sub-classes are doing
-            // what they are supposed to.
+            // Shouldn't be necessary but acts as a check that sub-classes are
+            // doing what they are supposed to.
             if (!state.equals(LifecycleState.STOPPING)) {
                 invalidTransition(Lifecycle.AFTER_STOP_EVENT);
             }
@@ -271,7 +281,12 @@ public abstract class LifecycleBase implements Lifecycle {
 
         setState(LifecycleState.DESTROYING);
         
-        destroyInternal();
+        try {
+            destroyInternal();
+        } catch (LifecycleException e) {
+            setState(LifecycleState.FAILED);
+            throw e;
+        }
         
         setState(LifecycleState.DESTROYED);
     }
index a3a04ac..f789d4e 100644 (file)
         the pool when a web application is stopped. (slaurent)
       </add>
       <fix>
+        <bug>49372</bug>: Re-fix after connector re-factoring. If connector
+        initialisation fails (e.g. if a port is alreasy in use) do not trigger
+        an <code>LifecycleException</code> for an invalid state transition.
+        (markt)
+      </fix>
+      <fix>
         <bug>49650</bug>: Remove unnecessary entries package.access property
         defined in catalina.properties. Patch provided by Owen Farrell. (markt) 
       </fix>