This is an automated email from the ASF dual-hosted git repository. rmaucher pushed a commit to branch 11.0.x in repository https://gitbox.apache.org/repos/asf/tomcat.git
commit 8135302139556e9d11c8857d47df95c961d06e9f Author: opencode <[email protected]> AuthorDate: Wed Sep 30 22:56:03 2026 +0200 Synchronize FileMessageFactory.isValid() with the write path and remove expired factories by instance to avoid racing with in-flight transfers --- java/org/apache/catalina/ha/deploy/FarmWarDeployer.java | 6 ++++-- java/org/apache/catalina/ha/deploy/FileMessageFactory.java | 2 +- 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/java/org/apache/catalina/ha/deploy/FarmWarDeployer.java b/java/org/apache/catalina/ha/deploy/FarmWarDeployer.java index 9772b2708d..34051a4156 100644 --- a/java/org/apache/catalina/ha/deploy/FarmWarDeployer.java +++ b/java/org/apache/catalina/ha/deploy/FarmWarDeployer.java @@ -803,8 +803,10 @@ public class FarmWarDeployer extends ClusterListener implements ClusterDeployer, String[] fileNames = fileFactories.keySet().toArray(new String[0]); for (String fileName : fileNames) { FileMessageFactory factory = fileFactories.get(fileName); - if (!factory.isValid()) { - fileFactories.remove(fileName); + if (factory != null && !factory.isValid()) { + // Remove with the factory instance to avoid evicting a newer + // factory created for a new transfer of the same file + fileFactories.remove(fileName, factory); } } } diff --git a/java/org/apache/catalina/ha/deploy/FileMessageFactory.java b/java/org/apache/catalina/ha/deploy/FileMessageFactory.java index 25590922c4..5a963da455 100644 --- a/java/org/apache/catalina/ha/deploy/FileMessageFactory.java +++ b/java/org/apache/catalina/ha/deploy/FileMessageFactory.java @@ -334,7 +334,7 @@ public class FileMessageFactory { * * @return True if the factory is still valid, false if it has expired */ - public boolean isValid() { + public synchronized boolean isValid() { if (maxValidTime > 0) { long timeNow = System.currentTimeMillis(); long timeIdle = (timeNow - lastModified) / 1000L; --------------------------------------------------------------------- To unsubscribe, e-mail: [email protected] For additional commands, e-mail: [email protected]
