This is an automated email from the ASF dual-hosted git repository.

markt-asf pushed a commit to branch 9.0.x
in repository https://gitbox.apache.org/repos/asf/tomcat.git


The following commit(s) were added to refs/heads/9.0.x by this push:
     new 5aa906e1b9 Avoid start then immediate stop when an error occurs with 
await enabled
5aa906e1b9 is described below

commit 5aa906e1b91627f2aaf4bb4d4b2ba8d8e7c83a44
Author: Mark Thomas <[email protected]>
AuthorDate: Thu Sep 17 14:42:14 2026 +0100

    Avoid start then immediate stop when an error occurs with await enabled
---
 java/org/apache/catalina/startup/Catalina.java | 9 ++++++++-
 webapps/docs/changelog.xml                     | 3 +++
 2 files changed, 11 insertions(+), 1 deletion(-)

diff --git a/java/org/apache/catalina/startup/Catalina.java 
b/java/org/apache/catalina/startup/Catalina.java
index 34dd19e506..141f458128 100644
--- a/java/org/apache/catalina/startup/Catalina.java
+++ b/java/org/apache/catalina/startup/Catalina.java
@@ -808,7 +808,14 @@ public class Catalina {
         try {
             getServer().init();
         } catch (LifecycleException e) {
-            if 
(Boolean.getBoolean("org.apache.catalina.startup.EXIT_ON_INIT_FAILURE")) {
+            if 
(Boolean.getBoolean("org.apache.catalina.startup.EXIT_ON_INIT_FAILURE") || 
await) {
+            /*
+             * The server will be in the FAILED state. If start() is then 
called, that will first call stop() to
+             * clean-up before trying to start the server. Calling stop() 
means a future call to getServer().await()
+             * will return immediately. That in turn means if the call to 
start() succeeds it will be immediately
+             * followed by another call to stop(). If await is enabled then it 
is better to throw the error here than to
+             * start the Server only to immediately stop it again.
+             */
                 throw new Error(e);
             } else {
                 log.error(sm.getString("catalina.initError"), e);
diff --git a/webapps/docs/changelog.xml b/webapps/docs/changelog.xml
index 2612650ea1..ceb5c2a83a 100644
--- a/webapps/docs/changelog.xml
+++ b/webapps/docs/changelog.xml
@@ -136,6 +136,9 @@
         <code>server.xml</code>. Use it to have <code>StoreConfig</code>
         save to a new config file. (remm)
       </fix>
+      <fix>
+        Improve error handling on start-up. (markt)
+      </fix>
     </changelog>
   </subsection>
 </section>


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to