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

markt 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 6197ecdda3 Fix race condition.
6197ecdda3 is described below

commit 6197ecdda3e50dae6a3d8a7c1c53e909576a41f0
Author: Mark Thomas <[email protected]>
AuthorDate: Fri Oct 10 14:25:23 2025 +0100

    Fix race condition.
---
 java/org/apache/catalina/session/FileStore.java | 4 ++--
 webapps/docs/changelog.xml                      | 4 ++++
 2 files changed, 6 insertions(+), 2 deletions(-)

diff --git a/java/org/apache/catalina/session/FileStore.java 
b/java/org/apache/catalina/session/FileStore.java
index 4fc202a6fc..5685229cdd 100644
--- a/java/org/apache/catalina/session/FileStore.java
+++ b/java/org/apache/catalina/session/FileStore.java
@@ -277,12 +277,12 @@ public final class FileStore extends StoreBase {
      * Return a File object representing the pathname to our session 
persistence directory, if any. The directory will
      * be created if it does not already exist.
      */
-    private File directory() throws IOException {
+    private synchronized File directory() throws IOException {
+        // Synchronised to avoid concurrent attempts to create the directory.
         if (this.directory == null) {
             return null;
         }
         if (this.directoryFile != null) {
-            // NOTE: Race condition is harmless, so do not synchronize
             return this.directoryFile;
         }
         File file = new File(this.directory);
diff --git a/webapps/docs/changelog.xml b/webapps/docs/changelog.xml
index b75a62e6ec..d3bf460f42 100644
--- a/webapps/docs/changelog.xml
+++ b/webapps/docs/changelog.xml
@@ -208,6 +208,10 @@
         entries are fully clean-up on session expiration. Patch provided by Kim
         Johan Andersson. (markt)
       </fix>
+      <fix>
+        Fix a race condition in the creation of the storage location for the
+        <code>FileStore</code>. (markt)
+      </fix>
     </changelog>
   </subsection>
   <subsection name="Coyote">


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

Reply via email to