Fix https://issues.apache.org/bugzilla/show_bug.cgi?id=51555
authormarkt <markt@13f79535-47bb-0310-9956-ffa450edef68>
Tue, 26 Jul 2011 08:25:46 +0000 (08:25 +0000)
committermarkt <markt@13f79535-47bb-0310-9956-ffa450edef68>
Tue, 26 Jul 2011 08:25:46 +0000 (08:25 +0000)
Permit an additional lifecycle transition. Allow destroy() to be called on components that are initialized. This can occur in some start failure scenarios.

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

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

index d1e3cde..eb2551f 100644 (file)
@@ -14,8 +14,6 @@
  * See the License for the specific language governing permissions and
  * limitations under the License.
  */
-
-
 package org.apache.catalina;
 
 
@@ -28,35 +26,38 @@ package org.apache.catalina;
  * The valid state transitions for components that support {@link Lifecycle}
  * are:
  * <pre>
- *    init()
- * NEW ->-- INITIALIZING
- * |||           |                  --------------------<-----------------------
- * |||           |auto              |                                          |
- * |||          \|/    start()     \|/       auto          auto         stop() |
- * |||      INITIALIZED -->-- STARTING_PREP -->- STARTING -->- STARTED -->---  |
- * |||                              ^                             |         |  |
- * |||        start()               |                             |         |  |
- * ||----------->--------------------                             |         |  |
- * ||                                                             |         |  |
- * |---                auto                    auto               |         |  |
- * |  |          ---------<----- MUST_STOP ---------------------<--         |  |
- * |  |          |                                                          |  |
- * |  |          ---------------------------<--------------------------------  ^
- * |  |          |                                                             |
- * |  |         \|/            auto                 auto              start()  |
- * |  |     STOPPING_PREP ------>----- STOPPING ------>----- STOPPED ---->------
- * |  |                                   ^                  |  |  ^
- * |  |                  stop()           |                  |  |  |
- * |  |          --------------------------                  |  |  |
- * |  |          |                                  auto     |  |  |
- * |  |          |                  MUST_DESTROY------<-------  |  |
- * |  |          |                    |                         |  |
- * |  |          |                    |auto                     |  |
- * |  |          |    destroy()      \|/              destroy() |  |
- * |  |       FAILED ---->------ DESTROYING ---<-----------------  |
- * |  |                           ^     |                          |
- * |  |        destroy()          |     |auto                      |
- * |  -----------------------------    \|/                         |
+ *            start()
+ *  -----------------------------
+ *  |                           |
+ *  | init()                    |
+ * NEW ->-- INITIALIZING        |
+ * | |           |              |     ------------------<-----------------------
+ * | |           |auto          |     |                                        |
+ * | |          \|/    start() \|/   \|/     auto          auto         stop() |
+ * | |      INITIALIZED -->-- STARTING_PREP -->- STARTING -->- STARTED -->---  |
+ * | |         |                                                  |         |  |
+ * | |         |                                                  |         |  |
+ * | |         |                                                  |         |  |
+ * | |destroy()|                                                  |         |  |
+ * | -->-----<--       auto                    auto               |         |  |
+ * |     |       ---------<----- MUST_STOP ---------------------<--         |  |
+ * |     |       |                                                          |  |
+ * |    \|/      ---------------------------<--------------------------------  ^
+ * |     |       |                                                             |
+ * |     |      \|/            auto                 auto              start()  |
+ * |     |  STOPPING_PREP ------>----- STOPPING ------>----- STOPPED ---->------
+ * |     |                                ^                  |  |  ^
+ * |     |               stop()           |                  |  |  |
+ * |     |       --------------------------                  |  |  |
+ * |     |       |                                  auto     |  |  |
+ * |     |       |                  MUST_DESTROY------<-------  |  |
+ * |     |       |                    |                         |  |
+ * |     |       |                    |auto                     |  |
+ * |     |       |    destroy()      \|/              destroy() |  |
+ * |     |    FAILED ---->------ DESTROYING ---<-----------------  |
+ * |     |                        ^     |                          |
+ * |     |     destroy()          |     |auto                      |
+ * |     -------->-----------------    \|/                         |
  * |                                 DESTROYED                     |
  * |                                                               |
  * |                            stop()                             |
@@ -93,7 +94,8 @@ package org.apache.catalina;
  * methods that trigger the changed. No {@link LifecycleEvent}s are fired if the
  * attempted transition is not valid.
  * 
- * TODO: Not all components may transition from STOPPED to STARTING_PREP
+ * TODO: Not all components may transition from STOPPED to STARTING_PREP. These
+ *       components should use MUST_DESTROY to signal this.
  *
  * @author Craig R. McClanahan
  * @version $Id$
index 66b6be2..72ed847 100644 (file)
@@ -274,7 +274,8 @@ public abstract class LifecycleBase implements Lifecycle {
         
         if (!state.equals(LifecycleState.STOPPED) &&
                 !state.equals(LifecycleState.FAILED) &&
-                !state.equals(LifecycleState.NEW)) {
+                !state.equals(LifecycleState.NEW) &&
+                !state.equals(LifecycleState.INITIALIZED)) {
             invalidTransition(Lifecycle.BEFORE_DESTROY_EVENT);
         }
 
index baf8fd9..442e8e5 100644 (file)
         Authenticators, now return a 500 response rather than a 200 response.
         (markt)
       </fix>
+      <fix>
+        <bug>51555</bug>: Allow destroy() to be called on Lifecycle components
+        that are in the initialized state. (markt)
+      </fix>
     </changelog>
   </subsection>
   <subsection name="Coyote">