This is an automated email from the ASF dual-hosted git repository. rmaucher pushed a commit to branch 9.0.x in repository https://gitbox.apache.org/repos/asf/tomcat.git
commit e2fccdfb03e024aca6af2e77bfd49764d3d25dfe Author: opencode <[email protected]> AuthorDate: Wed Sep 30 22:58:33 2026 +0200 Avoid logging a spurious delete failure for a context.xml that never existed and log a warning when a cluster undeploy targets a context that is not present on the node in FarmWarDeployer --- .../apache/catalina/ha/deploy/FarmWarDeployer.java | 40 ++++++++++++---------- .../catalina/ha/deploy/LocalStrings.properties | 1 + 2 files changed, 23 insertions(+), 18 deletions(-) diff --git a/java/org/apache/catalina/ha/deploy/FarmWarDeployer.java b/java/org/apache/catalina/ha/deploy/FarmWarDeployer.java index 27f27835a8..53d05a2993 100644 --- a/java/org/apache/catalina/ha/deploy/FarmWarDeployer.java +++ b/java/org/apache/catalina/ha/deploy/FarmWarDeployer.java @@ -474,25 +474,29 @@ public class FarmWarDeployer extends ClusterListener implements ClusterDeployer, // TODO Handle remove also work dir content ! // Stop the context first to be nicer Context context = (Context) host.findChild(contextName); - if (context != null) { - if (log.isDebugEnabled()) { - log.debug(sm.getString("farmWarDeployer.undeployLocal", contextName)); + if (context == null) { + if (log.isWarnEnabled()) { + log.warn(sm.getString("farmWarDeployer.contextNotFound", contextName)); } - context.stop(); - String baseName = context.getBaseName(); - File war = new File(host.getAppBaseFile(), baseName + ".war"); - File dir = new File(host.getAppBaseFile(), baseName); - File xml = new File(configBase, baseName + ".xml"); - if (war.exists()) { - if (!war.delete()) { - log.error(sm.getString("farmWarDeployer.deleteFail", war)); - } - } else if (dir.exists()) { - undeployDir(dir); - } else { - if (!xml.delete()) { - log.error(sm.getString("farmWarDeployer.deleteFail", xml)); - } + return; + } + if (log.isDebugEnabled()) { + log.debug(sm.getString("farmWarDeployer.undeployLocal", contextName)); + } + context.stop(); + String baseName = context.getBaseName(); + File war = new File(host.getAppBaseFile(), baseName + ".war"); + File dir = new File(host.getAppBaseFile(), baseName); + File xml = new File(configBase, baseName + ".xml"); + if (war.exists()) { + if (!war.delete()) { + log.error(sm.getString("farmWarDeployer.deleteFail", war)); + } + } else if (dir.exists()) { + undeployDir(dir); + } else { + if (xml.exists() && !xml.delete()) { + log.error(sm.getString("farmWarDeployer.deleteFail", xml)); } } } diff --git a/java/org/apache/catalina/ha/deploy/LocalStrings.properties b/java/org/apache/catalina/ha/deploy/LocalStrings.properties index b66dee0e8d..5d885bc60d 100644 --- a/java/org/apache/catalina/ha/deploy/LocalStrings.properties +++ b/java/org/apache/catalina/ha/deploy/LocalStrings.properties @@ -17,6 +17,7 @@ # To edit translations see: https://tomcat.apache.org/getinvolved.html#Translations farmWarDeployer.alreadyDeployed=webapp [{0}] are already deployed. +farmWarDeployer.contextNotFound=Unable to undeploy web app [{0}] locally since the context was not found on this node farmWarDeployer.delete=Deleted [{0}] before the full file was received as the maxValidTime of [{1}] seconds has expired farmWarDeployer.deleteFail=Failed to delete [{0}] farmWarDeployer.deployEnd=Deployment from [{0}] finished. --------------------------------------------------------------------- To unsubscribe, e-mail: [email protected] For additional commands, e-mail: [email protected]
