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
The following commit(s) were added to refs/heads/main by this push:
new a35f8b9bfd Follow-up to "Use a concurrent map for
WarWatcher.currentStatus..."
a35f8b9bfd is described below
commit a35f8b9bfd8b18e37f31d2ff61a183e4f9e5e818
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 03df921611..7b539a0ca2 100644
--- a/java/org/apache/catalina/ha/deploy/FarmWarDeployer.java
+++ b/java/org/apache/catalina/ha/deploy/FarmWarDeployer.java
@@ -64,7 +64,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.
@@ -97,12 +97,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
@@ -428,6 +428,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
@@ -460,6 +463,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()) {
@@ -542,6 +548,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]