This is an automated email from the ASF dual-hosted git repository. markt 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 6da76eff46 Complete fix for BZ 66513 6da76eff46 is described below commit 6da76eff4676fa7ed80bb7500238f874f16c216e 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 ccde599257..670f120748 100644 --- a/java/org/apache/catalina/valves/LocalStrings.properties +++ b/java/org/apache/catalina/valves/LocalStrings.properties @@ -130,7 +130,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 36fa4cfec6..d360933172 100644 --- a/java/org/apache/catalina/valves/PersistentValve.java +++ b/java/org/apache/catalina/valves/PersistentValve.java @@ -116,8 +116,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 @@ -145,12 +150,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; } } @@ -165,12 +176,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); @@ -185,8 +196,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. @@ -207,8 +218,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 { @@ -229,8 +240,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())) + @@ -238,8 +249,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 25e2de7c54..e295b8c37e 100644 --- a/webapps/docs/changelog.xml +++ b/webapps/docs/changelog.xml @@ -136,9 +136,11 @@ virtual threads. (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