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

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


The following commit(s) were added to refs/heads/10.1.x by this push:
     new 20136a25df Follow-up to "Use a concurrent map for 
WarWatcher.currentStatus..."
20136a25df is described below

commit 20136a25df6e4a07b04525486afbdc376ad79072
Author: Mark Thomas <[email protected]>
AuthorDate: Fri Oct 2 11:17:48 2026 +0100

    Follow-up to "Use a concurrent map for WarWatcher.currentStatus..."
    
    Fix a few concurrency issues in FarmWarDeployer
---
 java/org/apache/catalina/ha/deploy/FarmWarDeployer.java | 14 +++++++++++---
 1 file changed, 11 insertions(+), 3 deletions(-)

diff --git a/java/org/apache/catalina/ha/deploy/FarmWarDeployer.java 
b/java/org/apache/catalina/ha/deploy/FarmWarDeployer.java
index 220602d6f4..45db5214e6 100644
--- a/java/org/apache/catalina/ha/deploy/FarmWarDeployer.java
+++ b/java/org/apache/catalina/ha/deploy/FarmWarDeployer.java
@@ -62,7 +62,7 @@ public class FarmWarDeployer extends ClusterListener 
implements ClusterDeployer,
     /**
      * Whether the deployer has been started.
      */
-    protected boolean started = false;
+    protected volatile boolean started = false;
 
     /**
      * Map of file name to factory for in-progress file transfers.
@@ -95,12 +95,12 @@ public class FarmWarDeployer extends ClusterListener 
implements ClusterDeployer,
     /**
      * The watcher for monitoring the watch directory.
      */
-    protected WarWatcher watcher = null;
+    protected volatile WarWatcher watcher = null;
 
     /**
      * Iteration count for background processing.
      */
-    private int count = 0;
+    private volatile int count = 0;
 
     /**
      * Frequency of the Farm watchDir check. Cluster wide deployment will be 
done once for the specified amount of
@@ -424,6 +424,9 @@ public class FarmWarDeployer extends ClusterListener 
implements ClusterDeployer,
 
     @Override
     public void fileModified(File newWar) {
+        if (!started) {
+            return;
+        }
         try {
             ContextName cn = new ContextName(newWar.getName(), true);
             // Ensure deployed war uses lower case ".war" extension
@@ -456,6 +459,9 @@ public class FarmWarDeployer extends ClusterListener 
implements ClusterDeployer,
 
     @Override
     public void fileRemoved(File removeWar) {
+        if (!started) {
+            return;
+        }
         try {
             ContextName cn = new ContextName(removeWar.getName(), true);
             if (log.isInfoEnabled()) {
@@ -538,6 +544,8 @@ public class FarmWarDeployer extends ClusterListener 
implements ClusterDeployer,
      */
     @Override
     public void backgroundProcess() {
+        // Need to handle a concurrent call to stop() which nulls this.watcher
+        WarWatcher watcher = this.watcher;
         if (started) {
             if (watchEnabled) {
                 count = (count + 1) % processDeployFrequency;


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

Reply via email to