This is an automated email from the ASF dual-hosted git repository.
markt-asf pushed a commit to branch 9.0.x
in repository https://gitbox.apache.org/repos/asf/tomcat.git
The following commit(s) were added to refs/heads/9.0.x by this push:
new 5ab4ec6c11 Follow-up to "Use a concurrent map for
WarWatcher.currentStatus..."
5ab4ec6c11 is described below
commit 5ab4ec6c11197d8f7e67b7a5c8290b0cabb2d488
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 73702c5482..6bcf638e4e 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]