This is an automated email from the ASF dual-hosted git repository. markt-asf pushed a commit to branch main in repository https://gitbox.apache.org/repos/asf/tomcat.git
commit 4b000cc2f5ee44bc6d7b239490e41bab6d634123 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 a3334c973d..7fa1be7ddf 100644 --- a/java/org/apache/catalina/startup/Catalina.java +++ b/java/org/apache/catalina/startup/Catalina.java @@ -830,7 +830,14 @@ public class Catalina { try { getServer().init(); } catch (LifecycleException e) { - if (throwOnInitFailure) { + /* + * 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. + */ + if (throwOnInitFailure || await) { 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 7710a18e6b..7f458c0878 100644 --- a/webapps/docs/changelog.xml +++ b/webapps/docs/changelog.xml @@ -267,6 +267,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> <subsection name="Coyote"> --------------------------------------------------------------------- To unsubscribe, e-mail: [email protected] For additional commands, e-mail: [email protected]
