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 6a266f2c71 Fix potential race during session expiration.
6a266f2c71 is described below

commit 6a266f2c71ff7b0ebdd5d2815eb8c2ccd4fc6888
Author: Mark Thomas <[email protected]>
AuthorDate: Tue Oct 13 18:35:51 2026 +0100

    Fix potential race during session expiration.
---
 java/org/apache/catalina/session/StoreBase.java | 5 +++++
 1 file changed, 5 insertions(+)

diff --git a/java/org/apache/catalina/session/StoreBase.java 
b/java/org/apache/catalina/session/StoreBase.java
index bb59d72407..9465b6da7c 100644
--- a/java/org/apache/catalina/session/StoreBase.java
+++ b/java/org/apache/catalina/session/StoreBase.java
@@ -22,6 +22,7 @@ import java.io.BufferedInputStream;
 import java.io.IOException;
 import java.io.InputStream;
 import java.io.ObjectInputStream;
+import java.util.concurrent.locks.Lock;
 import java.util.concurrent.locks.ReadWriteLock;
 
 import org.apache.catalina.LifecycleException;
@@ -156,6 +157,8 @@ public abstract class StoreBase extends LifecycleBase 
implements Store {
         long timeNow = System.currentTimeMillis();
 
         for (String key : keys) {
+            Lock writeLock = getSessionStoreLock(key).writeLock();
+            writeLock.lock();
             try {
                 Session session = load(key);
                 if (session == null) {
@@ -197,6 +200,8 @@ public abstract class StoreBase extends LifecycleBase 
implements Store {
                 } catch (IOException ioe) {
                     
manager.getContext().getLogger().error(sm.getString("store.removeFail", key), 
ioe);
                 }
+            } finally {
+                writeLock.unlock();
             }
         }
     }


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

Reply via email to