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

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


The following commit(s) were added to refs/heads/11.0.x by this push:
     new 67a806859a Add protection against watchDir and deployDir being the same
67a806859a is described below

commit 67a806859ab3f968e7f829b6e08b2d1417c55374
Author: Mark Thomas <[email protected]>
AuthorDate: Wed Jun 24 21:12:58 2026 +0100

    Add protection against watchDir and deployDir being the same
---
 java/org/apache/catalina/ha/deploy/FarmWarDeployer.java    | 5 +++++
 java/org/apache/catalina/ha/deploy/LocalStrings.properties | 1 +
 2 files changed, 6 insertions(+)

diff --git a/java/org/apache/catalina/ha/deploy/FarmWarDeployer.java 
b/java/org/apache/catalina/ha/deploy/FarmWarDeployer.java
index f7b04b7265..20728e40e1 100644
--- a/java/org/apache/catalina/ha/deploy/FarmWarDeployer.java
+++ b/java/org/apache/catalina/ha/deploy/FarmWarDeployer.java
@@ -168,6 +168,9 @@ public class FarmWarDeployer extends ClusterListener 
implements ClusterDeployer,
             return;
         }
         if (watchEnabled) {
+            if 
(getDeployDirFile().getCanonicalPath().equals(getWatchDirFile().getCanonicalPath()))
 {
+                throw new 
IllegalStateException(sm.getString("farmWarDeployer.samePathDeployWatch"));
+            }
             watcher = new WarWatcher(this, getWatchDirFile());
             if (log.isInfoEnabled()) {
                 log.info(sm.getString("farmWarDeployer.watchDir", 
getWatchDir()));
@@ -617,6 +620,7 @@ public class FarmWarDeployer extends ClusterListener 
implements ClusterDeployer,
      */
     public void setDeployDir(String deployDir) {
         this.deployDir = deployDir;
+        deployDirFile = null;
     }
 
     /**
@@ -683,6 +687,7 @@ public class FarmWarDeployer extends ClusterListener 
implements ClusterDeployer,
      */
     public void setWatchDir(String watchDir) {
         this.watchDir = watchDir;
+        watchDirFile = null;
     }
 
     /**
diff --git a/java/org/apache/catalina/ha/deploy/LocalStrings.properties 
b/java/org/apache/catalina/ha/deploy/LocalStrings.properties
index fc9eb8ae0f..8194e0e440 100644
--- a/java/org/apache/catalina/ha/deploy/LocalStrings.properties
+++ b/java/org/apache/catalina/ha/deploy/LocalStrings.properties
@@ -37,6 +37,7 @@ farmWarDeployer.removeLocalFail=Unable to remove WAR file
 farmWarDeployer.removeStart=Cluster wide remove of web app [{0}]
 farmWarDeployer.removeTxMsg=Send cluster wide undeployment from [{0}]
 farmWarDeployer.renameFail=Failed to rename [{0}] to [{1}]
+farmWarDeployer.samePathDeployWatch=deployDir and watchDir must be different 
directories
 farmWarDeployer.sendEnd=Send cluster war deployment path [{0}], war [{1}] 
finished.
 farmWarDeployer.sendFragment=Send cluster war fragment path [{0}], war [{1}] 
to [{2}]
 farmWarDeployer.sendStart=Send cluster war deployment path [{0}], war [{1}] 
started.


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

Reply via email to