You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@tomcat.apache.org by re...@apache.org on 2026/10/01 07:54:33 UTC
(tomcat) 14/24: 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
This is an automated email from the ASF dual-hosted git repository.
rmaucher pushed a commit to branch 10.1.x
in repository https://gitbox.apache.org/repos/asf/tomcat.git
commit b01c6eb0dd070fc9dff011447eb22d87d983b001
Author: opencode <re...@apache.org>
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 bc1d427118..80626f2af1 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: dev-unsubscribe@tomcat.apache.org
For additional commands, e-mail: dev-help@tomcat.apache.org