You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@tomcat.apache.org by ma...@apache.org on 2023/06/01 17:11:55 UTC

[tomcat] branch 9.0.x updated: Complete fix for BZ 66513

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

markt 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 025ca91c6e Complete fix for BZ 66513
025ca91c6e is described below

commit 025ca91c6e6c59315ebe952503fb6ac471f94b2f
Author: Mark Thomas <ma...@apache.org>
AuthorDate: Thu Jun 1 18:06:18 2023 +0100

    Complete fix for BZ 66513
    
    https://bz.apache.org/bugzilla/show_bug.cgi?id=66513
---
 .../apache/catalina/valves/LocalStrings.properties |  4 +++
 .../apache/catalina/valves/PersistentValve.java    | 33 ++++++++++++++--------
 webapps/docs/changelog.xml                         |  6 ++--
 3 files changed, 30 insertions(+), 13 deletions(-)

diff --git a/java/org/apache/catalina/valves/LocalStrings.properties b/java/org/apache/catalina/valves/LocalStrings.properties
index 1bffd8f174..4ceab83a78 100644
--- a/java/org/apache/catalina/valves/LocalStrings.properties
+++ b/java/org/apache/catalina/valves/LocalStrings.properties
@@ -128,7 +128,11 @@ http.511.reason=Network Authentication Required
 jdbcAccessLogValve.close=Failed to close database
 jdbcAccessLogValve.exception=Exception performing insert access entry
 
+persistentValve.acquireFailed=The request for [{0}] did not obtain the per session Semaphore as no permit was available
+persistentValve.acquireInterrupted=The request for [{0}] did not obtain the per session Semaphore as it was interrupted while waiting for a permit
 persistentValve.filter.failure=Unable to compile filter=[{0}]
+persistentValve.requestIgnore=The request for [{0}] was ignored by this Valve as it matches the configured filter
+persistentValve.requestProcess=The request for [{0}] will be processed by this Valve as it does not match the configured filter
 
 remoteCidrValve.invalid=Invalid configuration provided for [{0}]. See previous messages for details.
 remoteCidrValve.noPort=Request does not contain a valid server port. Request denied.
diff --git a/java/org/apache/catalina/valves/PersistentValve.java b/java/org/apache/catalina/valves/PersistentValve.java
index 4f8dc9a6ec..d5c4c2a26e 100644
--- a/java/org/apache/catalina/valves/PersistentValve.java
+++ b/java/org/apache/catalina/valves/PersistentValve.java
@@ -117,8 +117,13 @@ public class PersistentValve extends ValveBase {
 
         // request without session
         if (isRequestWithoutSession(request.getDecodedRequestURI())) {
+            if (containerLog.isDebugEnabled()) {
+                containerLog.debug(sm.getString("persistentValve.requestIgnore", request.getDecodedRequestURI()));
+            }
             getNext().invoke(request, response);
             return;
+        } else if (containerLog.isDebugEnabled()) {
+            containerLog.debug(sm.getString("persistentValve.requestProcess", request.getDecodedRequestURI()));
         }
 
         // Select the Context to be used for this Request
@@ -146,12 +151,18 @@ public class PersistentValve extends ValveBase {
                         } catch (InterruptedException e) {
                             mustReleaseSemaphore = false;
                             onSemaphoreNotAcquired(request, response);
+                            if (containerLog.isDebugEnabled()) {
+                                containerLog.debug(sm.getString("persistentValve.acquireInterrupted", request.getDecodedRequestURI()));
+                            }
                             return;
                         }
                     }
                 } else {
                     if (!semaphore.tryAcquire()) {
                         onSemaphoreNotAcquired(request, response);
+                        if (containerLog.isDebugEnabled()) {
+                            containerLog.debug(sm.getString("persistentValve.acquireFailed", request.getDecodedRequestURI()));
+                        }
                         return;
                     }
                 }
@@ -166,12 +177,12 @@ public class PersistentValve extends ValveBase {
                     try {
                         session = store.load(sessionId);
                     } catch (Exception e) {
-                        container.getLogger().error("deserializeError");
+                        containerLog.error("deserializeError");
                     }
                     if (session != null) {
                         if (!session.isValid() || isSessionStale(session, System.currentTimeMillis())) {
-                            if (container.getLogger().isDebugEnabled()) {
-                                container.getLogger().debug("session swapped in is invalid or expired");
+                            if (containerLog.isDebugEnabled()) {
+                                containerLog.debug("session swapped in is invalid or expired");
                             }
                             session.expire();
                             store.remove(sessionId);
@@ -186,8 +197,8 @@ public class PersistentValve extends ValveBase {
                     }
                 }
             }
-            if (container.getLogger().isDebugEnabled()) {
-                container.getLogger().debug("sessionId: " + sessionId);
+            if (containerLog.isDebugEnabled()) {
+                containerLog.debug("sessionId: " + sessionId);
             }
 
             // Ask the next valve to process the request.
@@ -208,8 +219,8 @@ public class PersistentValve extends ValveBase {
                     newsessionId = hsess.getIdInternal();
                 }
 
-                if (container.getLogger().isDebugEnabled()) {
-                    container.getLogger().debug("newsessionId: " + newsessionId);
+                if (containerLog.isDebugEnabled()) {
+                    containerLog.debug("newsessionId: " + newsessionId);
                 }
                 if (newsessionId != null) {
                     try {
@@ -230,8 +241,8 @@ public class PersistentValve extends ValveBase {
                                 }
                             }
                             if (!stored) {
-                                if (container.getLogger().isDebugEnabled()) {
-                                    container.getLogger()
+                                if (containerLog.isDebugEnabled()) {
+                                    containerLog
                                             .debug("newsessionId store: " + store + " session: " + session +
                                                     " valid: " +
                                                     (session == null ? "N/A" : Boolean.toString(session.isValid())) +
@@ -239,8 +250,8 @@ public class PersistentValve extends ValveBase {
                                 }
                             }
                         } else {
-                            if (container.getLogger().isDebugEnabled()) {
-                                container.getLogger().debug("newsessionId Manager: " + manager);
+                            if (containerLog.isDebugEnabled()) {
+                                containerLog.debug("newsessionId Manager: " + manager);
                             }
                         }
                     } finally {
diff --git a/webapps/docs/changelog.xml b/webapps/docs/changelog.xml
index 9d7c3ec5d2..32b46dc9d4 100644
--- a/webapps/docs/changelog.xml
+++ b/webapps/docs/changelog.xml
@@ -124,9 +124,11 @@
         21. (markt)
       </add>
       <fix>
-        <bug>66513</bug>: Partial fix that adds a per session Semaphore to the
+        <bug>66513</bug>: Add a per session Semaphore to the
         <code>PersistentValve</code> that ensures that, within a single Tomcat
-        instance, there is no more than one concurrent request per session.
+        instance, there is no more than one concurrent request per session. Also
+        expand the debug logging to include whether a request bypasses the Valve
+        and the reason if a request fails to obtain the per session Semaphore.
         (markt)
       </fix>
       <fix>


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