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

markt-asf 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 4ddd98b61d Review "Record JSP usage time on every request, fixing 
premature..."
4ddd98b61d is described below

commit 4ddd98b61db8bc69e45dac3e6b1f144238bfa7f0
Author: Mark Thomas <[email protected]>
AuthorDate: Fri Nov 6 09:51:05 2026 +0000

    Review "Record JSP usage time on every request, fixing premature..."
    
    Fix concurrency issue tracking last queue update time
---
 java/org/apache/jasper/servlet/JspServletWrapper.java | 6 +++++-
 1 file changed, 5 insertions(+), 1 deletion(-)

diff --git a/java/org/apache/jasper/servlet/JspServletWrapper.java 
b/java/org/apache/jasper/servlet/JspServletWrapper.java
index 699f4b5444..82e838af06 100644
--- a/java/org/apache/jasper/servlet/JspServletWrapper.java
+++ b/java/org/apache/jasper/servlet/JspServletWrapper.java
@@ -86,6 +86,8 @@ public class JspServletWrapper {
     private volatile long servletClassLastModifiedTime;
     private long lastModificationTest = 0L;
     private long lastUsageTime = System.currentTimeMillis();
+    // Background unload cycle last observed by this wrapper's queue entry.
+    private long lastJspQueueUpdate;
     private FastRemovalDequeue<JspServletWrapper>.Entry unloadHandle;
     private final boolean unloadAllowed;
     private final boolean unloadByCount;
@@ -480,13 +482,15 @@ public class JspServletWrapper {
             if (unloadAllowed) {
                 synchronized (this) {
                     if (unloadByCount) {
+                        long jspQueueUpdate = 
ctxt.getRuntimeContext().getLastJspQueueUpdate();
                         if (unloadHandle == null) {
                             unloadHandle = ctxt.getRuntimeContext().push(this);
-                        } else if (lastUsageTime < 
ctxt.getRuntimeContext().getLastJspQueueUpdate()) {
+                        } else if (lastJspQueueUpdate != jspQueueUpdate) {
                             // Limit queue re-ordering to a single move per
                             // background checkUnload() cycle.
                             
ctxt.getRuntimeContext().makeYoungest(unloadHandle);
                         }
+                        lastJspQueueUpdate = jspQueueUpdate;
                     }
                     // Always record the usage time, so an actively used JSP is
                     // never seen as idle by checkUnload(), independent of how


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

Reply via email to