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

remm 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 e08ea94453 Fix resetting cross context sessions
e08ea94453 is described below

commit e08ea94453266e8222fd938e74ab2b180a00ca79
Author: remm <r...@apache.org>
AuthorDate: Wed Mar 19 19:57:08 2025 +0100

    Fix resetting cross context sessions
    
    Apparent logic error in the loop.
---
 java/org/apache/catalina/ha/tcp/ReplicationValve.java | 12 +++---------
 webapps/docs/changelog.xml                            |  8 ++++++++
 2 files changed, 11 insertions(+), 9 deletions(-)

diff --git a/java/org/apache/catalina/ha/tcp/ReplicationValve.java 
b/java/org/apache/catalina/ha/tcp/ReplicationValve.java
index 361a2fdd50..a5b3ed1af8 100644
--- a/java/org/apache/catalina/ha/tcp/ReplicationValve.java
+++ b/java/org/apache/catalina/ha/tcp/ReplicationValve.java
@@ -18,7 +18,6 @@ package org.apache.catalina.ha.tcp;
 
 import java.io.IOException;
 import java.util.ArrayList;
-import java.util.Iterator;
 import java.util.List;
 import java.util.concurrent.atomic.AtomicLong;
 import java.util.concurrent.atomic.LongAdder;
@@ -421,15 +420,10 @@ public class ReplicationValve extends ValveBase 
implements ClusterValve {
         }
         if (isCrossContext) {
             List<DeltaSession> sessions = crossContextSessions.get();
-            if (sessions != null && sessions.size() > 0) {
-                Iterator<DeltaSession> iter = sessions.iterator();
-                for (; iter.hasNext();) {
-                    Session session = iter.next();
+            if (sessions != null) {
+                for (DeltaSession session : sessions) {
                     resetDeltaRequest(session);
-                    if (session instanceof DeltaSession) {
-                        ((DeltaSession) 
contextSession).setPrimarySession(true);
-                    }
-
+                    session.setPrimarySession(true);
                 }
             }
         }
diff --git a/webapps/docs/changelog.xml b/webapps/docs/changelog.xml
index 27493be9ac..858f0ae2f2 100644
--- a/webapps/docs/changelog.xml
+++ b/webapps/docs/changelog.xml
@@ -161,6 +161,14 @@
       </scode>
     </changelog>
   </subsection>
+  <subsection name="Cluster">
+    <changelog>
+      <fix>
+        Fix resetting cross context sessions in the
+        <code>ReplicationValve</code>. (remm)
+      </fix>
+    </changelog>
+  </subsection>
   <subsection name="Web applications">
     <changelog>
       <add>


---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscr...@tomcat.apache.org
For additional commands, e-mail: dev-h...@tomcat.apache.org

Reply via email to