This is an automated email from the ASF dual-hosted git repository. markt pushed a commit to branch 8.5.x in repository https://gitbox.apache.org/repos/asf/tomcat.git
The following commit(s) were added to refs/heads/8.5.x by this push: new 41b216f089 Complete fix for BZ 66513 41b216f089 is described below commit 41b216f089ecfe2db539983096a9009fa566d208 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 5c168d257a..9bbdf8b083 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 @@ -153,12 +158,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; } } @@ -173,12 +184,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); @@ -193,8 +204,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. @@ -215,8 +226,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 { @@ -238,8 +249,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())) + @@ -247,8 +258,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 a3bb41bcdc..8048ec2cd8 100644 --- a/webapps/docs/changelog.xml +++ b/webapps/docs/changelog.xml @@ -115,9 +115,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-unsubscr...@tomcat.apache.org For additional commands, e-mail: dev-h...@tomcat.apache.org