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

rmaucher 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 ee647b1eac Code review fixes
ee647b1eac is described below

commit ee647b1eacceb9a6a6bb8b107ed225992770c5d2
Author: remm <[email protected]>
AuthorDate: Tue Jun 23 21:27:36 2026 +0200

    Code review fixes
---
 java/org/apache/catalina/Lifecycle.java            |  6 +-
 .../catalina/filters/CsrfPreventionFilter.java     |  4 +-
 .../catalina/filters/LocalStrings.properties       |  3 +
 .../apache/catalina/filters/RateLimitFilter.java   | 12 +++-
 .../catalina/filters/RequestDumperFilter.java      |  2 +-
 .../org/apache/catalina/filters/RequestFilter.java |  4 +-
 .../ha/authenticator/ClusterSingleSignOn.java      |  4 +-
 .../apache/catalina/ha/backend/CollectedInfo.java  | 12 +---
 .../catalina/ha/backend/HeartbeatListener.java     |  8 +--
 java/org/apache/catalina/ha/backend/TcpSender.java | 26 ++++++--
 .../catalina/ha/context/ReplicatedContext.java     |  1 -
 .../apache/catalina/ha/deploy/FarmWarDeployer.java |  5 +-
 .../catalina/ha/deploy/FileMessageFactory.java     |  5 +-
 java/org/apache/catalina/ha/deploy/WarWatcher.java |  5 +-
 .../ha/session/ClusterSessionListener.java         |  2 +-
 .../apache/catalina/ha/session/DeltaManager.java   | 77 +++++++++++-----------
 .../apache/catalina/ha/session/DeltaSession.java   |  1 +
 .../apache/catalina/ha/tcp/ReplicationValve.java   | 16 +++--
 .../apache/catalina/ha/tcp/SimpleTcpCluster.java   | 26 +++++---
 .../apache/jasper/runtime/JspRuntimeLibrary.java   |  2 +-
 webapps/docs/changelog.xml                         |  2 +-
 21 files changed, 124 insertions(+), 99 deletions(-)

diff --git a/java/org/apache/catalina/Lifecycle.java 
b/java/org/apache/catalina/Lifecycle.java
index 6792b2f0e0..8e9b91f9a8 100644
--- a/java/org/apache/catalina/Lifecycle.java
+++ b/java/org/apache/catalina/Lifecycle.java
@@ -196,7 +196,8 @@ public interface Lifecycle {
      * Prepare the component for starting. This method should perform any 
initialization required post object creation.
      * The following {@link LifecycleEvent}s will be fired in the following 
order:
      * <ol>
-     * <li>INIT_EVENT: On the successful completion of component 
initialization.</li>
+     * <li>BEFORE_INIT_EVENT: At the beginning of the method.</li>
+     * <li>AFTER_INIT_EVENT: On the successful completion of component 
initialization.</li>
      * </ol>
      *
      * @exception LifecycleException if this component detects a fatal error 
that prevents this component from being
@@ -250,7 +251,8 @@ public interface Lifecycle {
     /**
      * Prepare to discard the object. The following {@link LifecycleEvent}s 
will be fired in the following order:
      * <ol>
-     * <li>DESTROY_EVENT: On the successful completion of component 
destruction.</li>
+     * <li>BEFORE_DESTROY_EVENT: At the beginning of the method.</li>
+     * <li>AFTER_DESTROY_EVENT: On the successful completion of component 
destruction.</li>
      * </ol>
      *
      * @exception LifecycleException if this component detects a fatal error 
that prevents this component from being
diff --git a/java/org/apache/catalina/filters/CsrfPreventionFilter.java 
b/java/org/apache/catalina/filters/CsrfPreventionFilter.java
index 04cc2493a1..2b0ee326d7 100644
--- a/java/org/apache/catalina/filters/CsrfPreventionFilter.java
+++ b/java/org/apache/catalina/filters/CsrfPreventionFilter.java
@@ -54,7 +54,7 @@ import org.apache.tomcat.util.http.Method;
  * <ul>
  * <li>The filter is mapped to /*</li>
  * <li>{@link HttpServletResponse#encodeRedirectURL(String)} and {@link 
HttpServletResponse#encodeURL(String)} are used
- * to encode all URLs returned to the client
+ * to encode all URLs returned to the client</li>
  * </ul>
  * <p>
  * CSRF protection is enabled by generating random nonce values which are 
stored in the client's HTTP session. Each URL
@@ -67,7 +67,7 @@ import org.apache.tomcat.util.http.Method;
  * configured with the <code>entryPoints</code> filter <code>init-param</code>.
  * </p>
  * <p>
- * Some URLs should not have nonce parameters added to them at all
+ * Some URLs should not have nonce parameters added to them at all.
  */
 public class CsrfPreventionFilter extends CsrfPreventionFilterBase {
 
diff --git a/java/org/apache/catalina/filters/LocalStrings.properties 
b/java/org/apache/catalina/filters/LocalStrings.properties
index b17fbd0779..43e4bf0b6f 100644
--- a/java/org/apache/catalina/filters/LocalStrings.properties
+++ b/java/org/apache/catalina/filters/LocalStrings.properties
@@ -61,7 +61,10 @@ httpHeaderSecurityFilter.clickjack.invalid=An invalid value 
[{0}] was specified
 httpHeaderSecurityFilter.committed=Unable to add HTTP headers since response 
is already committed on entry to the HTTP header security Filter
 httpHeaderSecurityFilter.nullAntiClickJackingUri=Null value for anti click 
jacking URI
 
+rateLimitFilter.classNotFound=RateLimitFilter class name [{0}] not found
 rateLimitFilter.initialized=RateLimitFilter [{0}] initialized with [{1}] 
requests per [{2}] seconds. Actual is [{3}] per [{4}] seconds. [{5}].
+rateLimitFilter.invalidBucketDuration=Invalid bucket duration of [{0}] seconds 
specified
+rateLimitFilter.invalidBucketRequests=Invalid numbers of requests [{0}] per 
bucket specified
 rateLimitFilter.maxRequestsExceeded=[{0}] [{1}] Requests from [{2}] have 
exceeded the maximum allowed of [{3}] in a [{4}] second window.
 
 remoteCidrFilter.invalid=Invalid configuration provided for [{0}]. See 
previous messages for details.
diff --git a/java/org/apache/catalina/filters/RateLimitFilter.java 
b/java/org/apache/catalina/filters/RateLimitFilter.java
index 4d714bf865..dff5443fa7 100644
--- a/java/org/apache/catalina/filters/RateLimitFilter.java
+++ b/java/org/apache/catalina/filters/RateLimitFilter.java
@@ -166,6 +166,9 @@ public class RateLimitFilter extends FilterBase {
      * @param bucketDuration the duration in seconds
      */
     public void setBucketDuration(int bucketDuration) {
+        if (bucketDuration <= 0) {
+            throw new 
IllegalArgumentException(sm.getString("rateLimitFilter.invalidBucketDuration", 
Integer.valueOf(bucketDuration)));
+        }
         this.bucketDuration = bucketDuration;
     }
 
@@ -175,6 +178,9 @@ public class RateLimitFilter extends FilterBase {
      * @param bucketRequests the maximum number of requests
      */
     public void setBucketRequests(int bucketRequests) {
+        if (bucketRequests <= 0) {
+            throw new 
IllegalArgumentException(sm.getString("rateLimitFilter.invalidBucketRequests", 
Integer.valueOf(bucketRequests)));
+        }
         this.bucketRequests = bucketRequests;
     }
 
@@ -250,7 +256,7 @@ public class RateLimitFilter extends FilterBase {
         try {
             rateLimiter = (RateLimiter) 
Class.forName(rateLimitClassName).getConstructor().newInstance();
         } catch (ReflectiveOperationException e) {
-            throw new ServletException(e);
+            throw new 
ServletException(sm.getString("rateLimitFilter.classNotFound"), e);
         }
 
         rateLimiter.setDuration(bucketDuration);
@@ -312,7 +318,9 @@ public class RateLimitFilter extends FilterBase {
      */
     @Override
     public void destroy() {
-        rateLimiter.destroy();
+        if (rateLimiter != null) {
+            rateLimiter.destroy();
+        }
         super.destroy();
     }
 
diff --git a/java/org/apache/catalina/filters/RequestDumperFilter.java 
b/java/org/apache/catalina/filters/RequestDumperFilter.java
index 4a0ba267d9..a84b779f90 100644
--- a/java/org/apache/catalina/filters/RequestDumperFilter.java
+++ b/java/org/apache/catalina/filters/RequestDumperFilter.java
@@ -44,7 +44,7 @@ import org.apache.juli.logging.LogFactory;
  * </p>
  * <p>
  * When using this Filter, it is strongly recommended that the
- * <code>org.apache.catalina.filter.RequestDumperFilter</code> logger is 
directed to a dedicated file and that the
+ * <code>org.apache.catalina.filters.RequestDumperFilter</code> logger is 
directed to a dedicated file and that the
  * <code>org.apache.juli.VerbatimFormatter</code> is used.
  * </p>
  */
diff --git a/java/org/apache/catalina/filters/RequestFilter.java 
b/java/org/apache/catalina/filters/RequestFilter.java
index 6c4dae0600..ea829651c5 100644
--- a/java/org/apache/catalina/filters/RequestFilter.java
+++ b/java/org/apache/catalina/filters/RequestFilter.java
@@ -36,13 +36,13 @@ import jakarta.servlet.http.HttpServletResponse;
  * expressions (in the syntax supported by {@link Pattern}) to which the 
appropriate request property will be compared.
  * Evaluation proceeds as follows:
  * <ul>
- * <li>The subclass extracts the request property to be filtered, and calls 
the common <code>process()</code> method.
+ * <li>The subclass extracts the request property to be filtered, and calls 
the common <code>process()</code> method.</li>
  * <li>If there is a deny expression configured, the property will be compared 
to the expression. If a match is found,
  * this request will be rejected with a "Forbidden" HTTP response.</li>
  * <li>If there is an allow expression configured, the property will be 
compared to the expression. If a match is found,
  * this request will be allowed to pass through to the next filter in the 
current pipeline.</li>
  * <li>If a deny expression was specified but no allow expression, allow this 
request to pass through (because none of
- * the deny expressions matched it).
+ * the deny expressions matched it).</li>
  * <li>The request will be rejected with a "Forbidden" HTTP response.</li>
  * </ul>
  */
diff --git a/java/org/apache/catalina/ha/authenticator/ClusterSingleSignOn.java 
b/java/org/apache/catalina/ha/authenticator/ClusterSingleSignOn.java
index c8942f1692..22defbf66a 100644
--- a/java/org/apache/catalina/ha/authenticator/ClusterSingleSignOn.java
+++ b/java/org/apache/catalina/ha/authenticator/ClusterSingleSignOn.java
@@ -198,7 +198,7 @@ public class ClusterSingleSignOn extends SingleSignOn 
implements ClusterValve, M
      *                                   used
      */
     @Override
-    protected synchronized void startInternal() throws LifecycleException {
+    protected void startInternal() throws LifecycleException {
 
         // Load the cluster component, if any
         try {
@@ -238,7 +238,7 @@ public class ClusterSingleSignOn extends SingleSignOn 
implements ClusterValve, M
      *                                   used
      */
     @Override
-    protected synchronized void stopInternal() throws LifecycleException {
+    protected void stopInternal() throws LifecycleException {
 
         super.stopInternal();
 
diff --git a/java/org/apache/catalina/ha/backend/CollectedInfo.java 
b/java/org/apache/catalina/ha/backend/CollectedInfo.java
index dd3338cad3..43450ba206 100644
--- a/java/org/apache/catalina/ha/backend/CollectedInfo.java
+++ b/java/org/apache/catalina/ha/backend/CollectedInfo.java
@@ -16,8 +16,6 @@
  */
 package org.apache.catalina.ha.backend;
 
-/* for MBean to read ready and busy */
-
 import java.util.Set;
 
 import javax.management.MBeanServer;
@@ -27,16 +25,8 @@ import javax.management.ObjectName;
 import org.apache.tomcat.util.modeler.Registry;
 import org.apache.tomcat.util.res.StringManager;
 
-/*
- * Listener to provide information to mod_heartbeat.c
- * *msg_format = "v=%u&ready=%u&busy=%u"; (message to send).
- * send the multicast message using the format...
- * what about the bind(IP. port) only IP makes sense (for the moment).
- * BTW:v  = version :-)
- */
 /**
- * Listener to provide information to mod_heartbeat.c. Collects connector 
thread pool
- * information via JMX to report ready and busy thread counts.
+ * Collected information class.
  */
 public class CollectedInfo {
 
diff --git a/java/org/apache/catalina/ha/backend/HeartbeatListener.java 
b/java/org/apache/catalina/ha/backend/HeartbeatListener.java
index fde87dfcb4..b8b14799c1 100644
--- a/java/org/apache/catalina/ha/backend/HeartbeatListener.java
+++ b/java/org/apache/catalina/ha/backend/HeartbeatListener.java
@@ -23,15 +23,9 @@ import org.apache.juli.logging.Log;
 import org.apache.juli.logging.LogFactory;
 import org.apache.tomcat.util.res.StringManager;
 
-/*
- * Listener to provide information to mod_heartbeat.c
- * *msg_format = "v=%u&ready=%u&busy=%u"; (message to send).
- * send the multicast message using the format...
- * what about the bind(IP. port) only IP makes sense (for the moment).
- * BTW:v  = version :-)
- */
 /**
  * Lifecycle listener that provides heartbeat information to mod_heartbeat for 
Apache HTTP Server.
+ * Message format: "v=%u&ready=%u&busy=%u"
  */
 public class HeartbeatListener implements LifecycleListener {
 
diff --git a/java/org/apache/catalina/ha/backend/TcpSender.java 
b/java/org/apache/catalina/ha/backend/TcpSender.java
index 1c8a3c1bb9..9f80ea7f2b 100644
--- a/java/org/apache/catalina/ha/backend/TcpSender.java
+++ b/java/org/apache/catalina/ha/backend/TcpSender.java
@@ -73,6 +73,12 @@ public class TcpSender implements Sender {
 
     @Override
     public void init(HeartbeatListener config) throws Exception {
+        // Close any existing connections from a previous init
+        if (connections != null) {
+            for (int i = 0; i < connections.length; i++) {
+                close(i);
+            }
+        }
         this.config = config;
         StringTokenizer tok = new StringTokenizer(config.getProxyList(), ",");
         proxies = new Proxy[tok.countTokens()];
@@ -156,8 +162,14 @@ public class TcpSender implements Sender {
                 close(i);
                 continue;
             } else {
-                responseStatus = 
responseStatus.substring(responseStatus.indexOf(' ') + 1,
-                        responseStatus.indexOf(' ', responseStatus.indexOf(' 
') + 1));
+                int firstSpace = responseStatus.indexOf(' ');
+                int secondSpace = responseStatus.indexOf(' ', firstSpace + 1);
+                if (firstSpace < 0 || secondSpace < 0 || secondSpace <= 
firstSpace + 1) {
+                    log.error(sm.getString("tcpSender.responseError"));
+                    close(i);
+                    continue;
+                }
+                responseStatus = responseStatus.substring(firstSpace + 1, 
secondSpace);
                 int status = 500;
                 try {
                     status = Integer.parseInt(responseStatus);
@@ -175,10 +187,12 @@ public class TcpSender implements Sender {
                 int contentLength = 0;
                 while (header != null && !header.isEmpty()) {
                     int colon = header.indexOf(':');
-                    String headerName = header.substring(0, colon).trim();
-                    String headerValue = header.substring(colon + 1).trim();
-                    if ("content-length".equalsIgnoreCase(headerName)) {
-                        contentLength = Integer.parseInt(headerValue);
+                    if (colon >= 0 && header.length() > (colon + 1)) {
+                        String headerName = header.substring(0, colon).trim();
+                        String headerValue = header.substring(colon + 
1).trim();
+                        if ("content-length".equalsIgnoreCase(headerName)) {
+                            contentLength = Integer.parseInt(headerValue);
+                        }
                     }
                     header = connectionReaders[i].readLine();
                 }
diff --git a/java/org/apache/catalina/ha/context/ReplicatedContext.java 
b/java/org/apache/catalina/ha/context/ReplicatedContext.java
index 4d0bb30037..bc7f28913c 100644
--- a/java/org/apache/catalina/ha/context/ReplicatedContext.java
+++ b/java/org/apache/catalina/ha/context/ReplicatedContext.java
@@ -217,7 +217,6 @@ public class ReplicatedContext extends StandardContext 
implements MapOwner {
         @Override
         public void removeAttribute(String name) {
             tomcatAttributes.remove(name);
-            // do nothing
             super.removeAttribute(name);
         }
 
diff --git a/java/org/apache/catalina/ha/deploy/FarmWarDeployer.java 
b/java/org/apache/catalina/ha/deploy/FarmWarDeployer.java
index b979f34069..ba20be8392 100644
--- a/java/org/apache/catalina/ha/deploy/FarmWarDeployer.java
+++ b/java/org/apache/catalina/ha/deploy/FarmWarDeployer.java
@@ -20,7 +20,8 @@ import java.io.File;
 import java.io.FileNotFoundException;
 import java.io.IOException;
 import java.nio.file.Files;
-import java.util.HashMap;
+import java.util.Map;
+import java.util.concurrent.ConcurrentHashMap;
 
 import javax.management.MBeanServer;
 import javax.management.ObjectName;
@@ -67,7 +68,7 @@ public class FarmWarDeployer extends ClusterListener 
implements ClusterDeployer,
     /**
      * Map of file name to factory for in-progress file transfers.
      */
-    protected final HashMap<String,FileMessageFactory> fileFactories = new 
HashMap<>();
+    protected final Map<String,FileMessageFactory> fileFactories = new 
ConcurrentHashMap<>();
 
     /**
      * Deployment directory.
diff --git a/java/org/apache/catalina/ha/deploy/FileMessageFactory.java 
b/java/org/apache/catalina/ha/deploy/FileMessageFactory.java
index 90f0680b00..4c49bfac29 100644
--- a/java/org/apache/catalina/ha/deploy/FileMessageFactory.java
+++ b/java/org/apache/catalina/ha/deploy/FileMessageFactory.java
@@ -271,7 +271,7 @@ public class FileMessageFactory {
     /**
      * Closes the factory, its streams and sets all its references to null
      */
-    public void cleanup() {
+    public synchronized void cleanup() {
         if (in != null) {
             try {
                 in.close();
@@ -294,7 +294,8 @@ public class FileMessageFactory {
         nrOfMessagesProcessed = 0;
         totalNrOfMessages = 0;
         msgBuffer.clear();
-        lastMessageProcessed = null;
+        lastMessageProcessed.set(0);
+        isWriting = false;
     }
 
     /**
diff --git a/java/org/apache/catalina/ha/deploy/WarWatcher.java 
b/java/org/apache/catalina/ha/deploy/WarWatcher.java
index 2d0d2a0847..9a6ae19440 100644
--- a/java/org/apache/catalina/ha/deploy/WarWatcher.java
+++ b/java/org/apache/catalina/ha/deploy/WarWatcher.java
@@ -19,6 +19,7 @@ package org.apache.catalina.ha.deploy;
 import java.io.File;
 import java.util.HashMap;
 import java.util.Iterator;
+import java.util.Locale;
 import java.util.Map;
 
 import org.apache.juli.logging.Log;
@@ -149,7 +150,7 @@ public class WarWatcher {
             if (name == null) {
                 return false;
             }
-            return name.endsWith(".war");
+            return name.toLowerCase(Locale.ENGLISH).endsWith(".war");
         }
     }
 
@@ -170,7 +171,7 @@ public class WarWatcher {
         /**
          * The last known state of the file.
          */
-        protected long lastState = 0;
+        protected int lastState = 0;
 
         /**
          * Constructs a new WarInfo.
diff --git a/java/org/apache/catalina/ha/session/ClusterSessionListener.java 
b/java/org/apache/catalina/ha/session/ClusterSessionListener.java
index e8cb385be5..95199cce66 100644
--- a/java/org/apache/catalina/ha/session/ClusterSessionListener.java
+++ b/java/org/apache/catalina/ha/session/ClusterSessionListener.java
@@ -26,7 +26,7 @@ import org.apache.juli.logging.LogFactory;
 import org.apache.tomcat.util.res.StringManager;
 
 /**
- * Receive replicated SessionMessage form other cluster node.
+ * Receive replicated SessionMessage from other cluster node.
  */
 public class ClusterSessionListener extends ClusterListener {
 
diff --git a/java/org/apache/catalina/ha/session/DeltaManager.java 
b/java/org/apache/catalina/ha/session/DeltaManager.java
index 268e090ec7..9423498ddc 100644
--- a/java/org/apache/catalina/ha/session/DeltaManager.java
+++ b/java/org/apache/catalina/ha/session/DeltaManager.java
@@ -135,7 +135,7 @@ public class DeltaManager extends ClusterManagerBase {
         return name;
     }
 
-  /**
+    /**
      * Get the send counter for EVT_GET_ALL_SESSIONS events.
      *
      * @return the counterSend_EVT_GET_ALL_SESSIONS value.
@@ -144,7 +144,7 @@ public class DeltaManager extends ClusterManagerBase {
         return counterSend_EVT_GET_ALL_SESSIONS.get();
     }
 
-  /**
+    /**
      * Get the send counter for EVT_SESSION_ACCESSED events.
      *
      * @return the counterSend_EVT_SESSION_ACCESSED value.
@@ -153,7 +153,7 @@ public class DeltaManager extends ClusterManagerBase {
         return counterSend_EVT_SESSION_ACCESSED.get();
     }
 
-  /**
+    /**
      * Get the send counter for EVT_SESSION_CREATED events.
      *
      * @return the counterSend_EVT_SESSION_CREATED value.
@@ -162,7 +162,7 @@ public class DeltaManager extends ClusterManagerBase {
         return counterSend_EVT_SESSION_CREATED.get();
     }
 
-  /**
+    /**
      * Get the send counter for EVT_SESSION_DELTA events.
      *
      * @return the counterSend_EVT_SESSION_DELTA value.
@@ -171,7 +171,7 @@ public class DeltaManager extends ClusterManagerBase {
         return counterSend_EVT_SESSION_DELTA.get();
     }
 
-  /**
+    /**
      * Get the send counter for EVT_SESSION_EXPIRED events.
      *
      * @return the counterSend_EVT_SESSION_EXPIRED value.
@@ -180,7 +180,7 @@ public class DeltaManager extends ClusterManagerBase {
         return counterSend_EVT_SESSION_EXPIRED.get();
     }
 
-  /**
+    /**
      * Get the send counter for EVT_ALL_SESSION_DATA events.
      *
      * @return the counterSend_EVT_ALL_SESSION_DATA value.
@@ -189,7 +189,7 @@ public class DeltaManager extends ClusterManagerBase {
         return counterSend_EVT_ALL_SESSION_DATA.get();
     }
 
-  /**
+    /**
      * Get the send counter for EVT_ALL_SESSION_TRANSFERCOMPLETE events.
      *
      * @return the counterSend_EVT_ALL_SESSION_TRANSFERCOMPLETE value.
@@ -198,7 +198,7 @@ public class DeltaManager extends ClusterManagerBase {
         return counterSend_EVT_ALL_SESSION_TRANSFERCOMPLETE.get();
     }
 
-  /**
+    /**
      * Get the send counter for EVT_CHANGE_SESSION_ID events.
      *
      * @return the counterSend_EVT_CHANGE_SESSION_ID value.
@@ -207,7 +207,7 @@ public class DeltaManager extends ClusterManagerBase {
         return counterSend_EVT_CHANGE_SESSION_ID.get();
     }
 
-  /**
+    /**
      * Get the receive counter for EVT_ALL_SESSION_DATA events.
      *
      * @return the counterReceive_EVT_ALL_SESSION_DATA value.
@@ -216,7 +216,7 @@ public class DeltaManager extends ClusterManagerBase {
         return counterReceive_EVT_ALL_SESSION_DATA.get();
     }
 
-  /**
+    /**
      * Get the receive counter for EVT_GET_ALL_SESSIONS events.
      *
      * @return the counterReceive_EVT_GET_ALL_SESSIONS value.
@@ -225,7 +225,7 @@ public class DeltaManager extends ClusterManagerBase {
         return counterReceive_EVT_GET_ALL_SESSIONS.get();
     }
 
- /**
+    /**
      * Get the receive counter for EVT_SESSION_ACCESSED events.
      *
      * @return the counterReceive_EVT_SESSION_ACCESSED value.
@@ -234,7 +234,7 @@ public class DeltaManager extends ClusterManagerBase {
         return counterReceive_EVT_SESSION_ACCESSED.get();
     }
 
- /**
+    /**
      * Get the receive counter for EVT_SESSION_CREATED events.
      *
      * @return the counterReceive_EVT_SESSION_CREATED value.
@@ -243,7 +243,7 @@ public class DeltaManager extends ClusterManagerBase {
         return counterReceive_EVT_SESSION_CREATED.get();
     }
 
- /**
+    /**
      * Get the receive counter for EVT_SESSION_DELTA events.
      *
      * @return the counterReceive_EVT_SESSION_DELTA value.
@@ -252,7 +252,7 @@ public class DeltaManager extends ClusterManagerBase {
         return counterReceive_EVT_SESSION_DELTA.get();
     }
 
- /**
+    /**
      * Get the receive counter for EVT_SESSION_EXPIRED events.
      *
      * @return the counterReceive_EVT_SESSION_EXPIRED value.
@@ -262,7 +262,7 @@ public class DeltaManager extends ClusterManagerBase {
     }
 
 
- /**
+    /**
      * Get the receive counter for EVT_ALL_SESSION_TRANSFERCOMPLETE events.
      *
      * @return the counterReceive_EVT_ALL_SESSION_TRANSFERCOMPLETE value.
@@ -271,7 +271,7 @@ public class DeltaManager extends ClusterManagerBase {
         return counterReceive_EVT_ALL_SESSION_TRANSFERCOMPLETE.get();
     }
 
- /**
+    /**
      * Get the receive counter for EVT_CHANGE_SESSION_ID events.
      *
      * @return the counterReceive_EVT_CHANGE_SESSION_ID value.
@@ -280,7 +280,7 @@ public class DeltaManager extends ClusterManagerBase {
         return counterReceive_EVT_CHANGE_SESSION_ID.get();
     }
 
- /**
+    /**
      * Get the receive counter for EVT_ALL_SESSION_NOCONTEXTMANAGER events.
      *
      * @return the counterReceive_EVT_ALL_SESSION_NOCONTEXTMANAGER value.
@@ -289,7 +289,7 @@ public class DeltaManager extends ClusterManagerBase {
         return counterReceive_EVT_ALL_SESSION_NOCONTEXTMANAGER.get();
     }
 
- /**
+    /**
      * Get the session replace counter.
      *
      * @return the sessionReplaceCounter value.
@@ -298,7 +298,7 @@ public class DeltaManager extends ClusterManagerBase {
         return sessionReplaceCounter.get();
     }
 
- /**
+    /**
      * Get the counter for sessions where no state was transferred.
      *
      * @return the counterNoStateTransferred value.
@@ -318,7 +318,7 @@ public class DeltaManager extends ClusterManagerBase {
         }
     }
 
- /**
+    /**
      * Get the state transfer timeout value.
      *
      * @return the stateTransferTimeout value.
@@ -327,7 +327,7 @@ public class DeltaManager extends ClusterManagerBase {
         return stateTransferTimeout;
     }
 
-  /**
+    /**
      * Set the state transfer timeout.
      *
      * @param timeoutAllSession The timeout value
@@ -336,7 +336,7 @@ public class DeltaManager extends ClusterManagerBase {
         this.stateTransferTimeout = timeoutAllSession;
     }
 
-  /**
+    /**
      * Check if the state transfer is complete.
      *
      * @return <code>true</code> if the state transfer is complete.
@@ -372,7 +372,7 @@ public class DeltaManager extends ClusterManagerBase {
         this.noContextManagerReceived = noContextManagerReceived;
     }
 
-  /**
+    /**
      * Get the wait time for sending all sessions.
      *
      * @return the sendAllSessionsWaitTime in milliseconds
@@ -381,7 +381,7 @@ public class DeltaManager extends ClusterManagerBase {
         return sendAllSessionsWaitTime;
     }
 
- /**
+    /**
      * Set the wait time for sending all sessions.
      *
      * @param sendAllSessionsWaitTime The wait time in milliseconds
@@ -390,7 +390,7 @@ public class DeltaManager extends ClusterManagerBase {
         this.sendAllSessionsWaitTime = sendAllSessionsWaitTime;
     }
 
- /**
+    /**
      * Check if state timestamp drop is enabled.
      *
      * @return the stateTimestampDrop flag
@@ -399,7 +399,7 @@ public class DeltaManager extends ClusterManagerBase {
         return stateTimestampDrop;
     }
 
- /**
+    /**
      * Set the state timestamp drop flag.
      *
      * @param isTimestampDrop The new flag value
@@ -408,7 +408,7 @@ public class DeltaManager extends ClusterManagerBase {
         this.stateTimestampDrop = isTimestampDrop;
     }
 
- /**
+    /**
      * Check if sending all sessions is enabled.
      *
      * @return the sendAllSessions flag
@@ -417,7 +417,7 @@ public class DeltaManager extends ClusterManagerBase {
         return sendAllSessions;
     }
 
- /**
+    /**
      * Set whether to send all sessions during replication.
      *
      * @param sendAllSessions The flag value
@@ -426,7 +426,7 @@ public class DeltaManager extends ClusterManagerBase {
         this.sendAllSessions = sendAllSessions;
     }
 
- /**
+    /**
      * Get the batch size for sending all sessions.
      *
      * @return the sendAllSessionsSize value
@@ -435,7 +435,7 @@ public class DeltaManager extends ClusterManagerBase {
         return sendAllSessionsSize;
     }
 
- /**
+    /**
      * Set the batch size for sending all sessions.
      *
      * @param sendAllSessionsSize The batch size value
@@ -444,7 +444,7 @@ public class DeltaManager extends ClusterManagerBase {
         this.sendAllSessionsSize = sendAllSessionsSize;
     }
 
- /**
+    /**
      * Check if session listeners are notified on replication.
      *
      * @return the notifySessionListenersOnReplication flag
@@ -453,13 +453,13 @@ public class DeltaManager extends ClusterManagerBase {
         return notifySessionListenersOnReplication;
     }
 
- /**
+    /**
      * Set whether to notify session listeners on replication.
      *
-     * @param notifyListenersCreateSessionOnReplication The flag value
+     * @param notifySessionListenersOnReplication The flag value
      */
-    public void setNotifySessionListenersOnReplication(boolean 
notifyListenersCreateSessionOnReplication) {
-        this.notifySessionListenersOnReplication = 
notifyListenersCreateSessionOnReplication;
+    public void setNotifySessionListenersOnReplication(boolean 
notifySessionListenersOnReplication) {
+        this.notifySessionListenersOnReplication = 
notifySessionListenersOnReplication;
     }
 
 
@@ -499,7 +499,7 @@ public class DeltaManager extends ClusterManagerBase {
         this.notifyContainerListenersOnReplication = 
notifyContainerListenersOnReplication;
     }
 
-/**
+    /**
      * Check if statistics collection is enabled.
      *
      * @return the enableStatistics flag
@@ -508,7 +508,7 @@ public class DeltaManager extends ClusterManagerBase {
         return this.enableStatistics;
     }
 
-/**
+    /**
      * Set whether statistics collection is enabled.
      *
      * @param enableStatistics The flag value
@@ -1377,7 +1377,7 @@ public class DeltaManager extends ClusterManagerBase {
     }
 
     /**
-     * handle receive sessions from other not ( restart )
+     * Handle receive sessions from other node ( restart )
      *
      * @param msg    Session message
      * @param sender Member which sent the message
@@ -1398,7 +1398,6 @@ public class DeltaManager extends ClusterManagerBase {
         if (log.isDebugEnabled()) {
             
log.debug(sm.getString("deltaManager.receiveMessage.allSessionDataAfter", 
getName()));
         }
-        // stateTransferred = true;
     }
 
     /**
diff --git a/java/org/apache/catalina/ha/session/DeltaSession.java 
b/java/org/apache/catalina/ha/session/DeltaSession.java
index 86eb16f609..4a517de988 100644
--- a/java/org/apache/catalina/ha/session/DeltaSession.java
+++ b/java/org/apache/catalina/ha/session/DeltaSession.java
@@ -260,6 +260,7 @@ public class DeltaSession extends StandardSession 
implements Externalizable, Clu
     @Override
     public boolean isAccessReplicate() {
         long replDelta = System.currentTimeMillis() - getLastTimeReplicated();
+        int maxInactiveInterval = getMaxInactiveInterval();
         return maxInactiveInterval >= 0 && replDelta > (maxInactiveInterval * 
1000L);
     }
 
diff --git a/java/org/apache/catalina/ha/tcp/ReplicationValve.java 
b/java/org/apache/catalina/ha/tcp/ReplicationValve.java
index 99beaa83e4..997e6adab9 100644
--- a/java/org/apache/catalina/ha/tcp/ReplicationValve.java
+++ b/java/org/apache/catalina/ha/tcp/ReplicationValve.java
@@ -298,10 +298,10 @@ public class ReplicationValve extends ValveBase 
implements ClusterValve {
     // --------------------------------------------------------- Public Methods
 
     /**
-     * Register all cross context sessions inside endAccess. Use a list with 
contains check, that the Portlet API can
-     * include a lot of fragments from same or different applications with 
session changes.
+     * Register a cross-context session for replication. The session is added 
to
+     * the current thread's cross-context session list if it is not already 
present.
      *
-     * @param session cross context session
+     * @param session the cross-context session to register
      */
     public void registerReplicationSession(DeltaSession session) {
         List<DeltaSession> sessions = crossContextSessions.get();
@@ -608,8 +608,14 @@ public class ReplicationValve extends ValveBase implements 
ClusterValve {
     protected void createPrimaryIndicator(Request request) throws IOException {
         String id = request.getRequestedSessionId();
         if ((id != null) && (!id.isEmpty())) {
-            Manager manager = request.getContext().getManager();
-            Session session = manager.findSession(id);
+            Context ctx = request.getContext();
+            Session session = null;
+            if (ctx != null) {
+                Manager manager = ctx.getManager();
+                if (manager != null) {
+                    session = manager.findSession(id);
+                }
+            }
             if (session instanceof ClusterSession cses) {
                 if (log.isDebugEnabled()) {
                     
log.debug(sm.getString("ReplicationValve.session.indicator", 
request.getContext().getName(), id,
diff --git a/java/org/apache/catalina/ha/tcp/SimpleTcpCluster.java 
b/java/org/apache/catalina/ha/tcp/SimpleTcpCluster.java
index 06016ab7e1..1ca655f6f7 100644
--- a/java/org/apache/catalina/ha/tcp/SimpleTcpCluster.java
+++ b/java/org/apache/catalina/ha/tcp/SimpleTcpCluster.java
@@ -32,6 +32,7 @@ import org.apache.catalina.Host;
 import org.apache.catalina.LifecycleException;
 import org.apache.catalina.LifecycleState;
 import org.apache.catalina.Manager;
+import org.apache.catalina.Service;
 import org.apache.catalina.Valve;
 import org.apache.catalina.ha.CatalinaCluster;
 import org.apache.catalina.ha.ClusterDeployer;
@@ -57,7 +58,7 @@ import org.apache.tomcat.util.res.StringManager;
 
 /**
  * A <b>Cluster </b> implementation using simple multicast. Responsible for 
setting up a cluster and provides callers
- * with a valid multicast receiver/sender.
+ * with a valid message receiver/sender.
  */
 public class SimpleTcpCluster extends LifecycleMBeanBase
         implements CatalinaCluster, MembershipListener, ChannelListener {
@@ -590,7 +591,10 @@ public class SimpleTcpCluster extends LifecycleMBeanBase
             log.info(sm.getString("simpleTcpCluster.start"));
         }
 
-        
channel.setUtilityExecutor(Container.getService(getContainer()).getServer().getUtilityExecutor());
+        Service service = Container.getService(getContainer());
+        if (service != null && service.getServer() != null) {
+            
channel.setUtilityExecutor(service.getServer().getUtilityExecutor());
+        }
 
         try {
             checkDefaults();
@@ -660,14 +664,16 @@ public class SimpleTcpCluster extends LifecycleMBeanBase
      * unregister all cluster valve to host or engine
      */
     protected void unregisterClusterValve() {
-        for (Valve v : valves) {
-            ClusterValve valve = (ClusterValve) v;
-            if (log.isTraceEnabled()) {
-                log.trace("Invoking removeValve on " + getContainer() + " with 
class=" + valve.getClass().getName());
-            }
-            if (valve != null) {
-                container.getPipeline().removeValve(valve);
-                valve.setCluster(null);
+        if (container != null) {
+            for (Valve v : valves) {
+                ClusterValve valve = (ClusterValve) v;
+                if (log.isTraceEnabled()) {
+                    log.trace("Invoking removeValve on " + getContainer() + " 
with class=" + valve.getClass().getName());
+                }
+                if (valve != null) {
+                    container.getPipeline().removeValve(valve);
+                    valve.setCluster(null);
+                }
             }
         }
     }
diff --git a/java/org/apache/jasper/runtime/JspRuntimeLibrary.java 
b/java/org/apache/jasper/runtime/JspRuntimeLibrary.java
index 63ea44efe7..c238da17a3 100644
--- a/java/org/apache/jasper/runtime/JspRuntimeLibrary.java
+++ b/java/org/apache/jasper/runtime/JspRuntimeLibrary.java
@@ -1220,7 +1220,7 @@ public class JspRuntimeLibrary {
 
 
     /**
-     * Releases a tag and destroys its instance it it has not been re-used.
+     * Releases a tag and destroys its instance if it has not been re-used.
      *
      * @param tag The tag to release
      * @param instanceManager The instance manager
diff --git a/webapps/docs/changelog.xml b/webapps/docs/changelog.xml
index dbcc9c2216..9034345b47 100644
--- a/webapps/docs/changelog.xml
+++ b/webapps/docs/changelog.xml
@@ -305,7 +305,7 @@
       </add>
       <!-- Entries for backport and removal before 12.0.0-M1 below this line 
-->
       <fix>
-        <bug>70120</bug>: The fix for <bug>69699</bug> (itself a fix for a
+        <bug>70120</bug>: The fix for <bug>69399</bug> (itself a fix for a
         regression in the fix for <bug>69333</bug>) was incomplete and tags 
that
         threw exceptions in <code>doStartTag()</code> and
         <code>doEndTag()</code> were incorrectly re-used. This fix prevents 
tags


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


Reply via email to