Rearrange placement of JSP limter code in JSP
authorrjung <rjung@13f79535-47bb-0310-9956-ffa450edef68>
Fri, 29 Oct 2010 17:47:01 +0000 (17:47 +0000)
committerrjung <rjung@13f79535-47bb-0310-9956-ffa450edef68>
Fri, 29 Oct 2010 17:47:01 +0000 (17:47 +0000)
servlet wrapper. Do everything in one place:

- add to the queue if this is the first time
  and only then check for the size and shrink
  if necessary

- move to the front of the queue otherwise

Move this in front of the actual servlet service.

git-svn-id: https://svn.apache.org/repos/asf/tomcat/trunk@1028862 13f79535-47bb-0310-9956-ffa450edef68

java/org/apache/jasper/servlet/JspServletWrapper.java

index 0bbbb16..811fe19 100644 (file)
@@ -325,10 +325,6 @@ public class JspServletWrapper {
 
                     // The following sets reload to true, if necessary
                     ctxt.compile();
-                    
-                    if (options.getMaxLoadedJsps() > 0) {
-                        ctxt.getRuntimeContext().unloadJsp();
-                    }
                 }
             } else {
                 if (compileException != null) {
@@ -375,7 +371,20 @@ public class JspServletWrapper {
         try {
             
             /*
-             * (3) Service request
+             * (3) Handle limitation of number of loaded Jsps
+             */
+            if (options.getMaxLoadedJsps() > 0) {
+                synchronized(this) {
+                    if (ticket == null) {
+                        ticket = ctxt.getRuntimeContext().push(this);
+                        ctxt.getRuntimeContext().unloadJsp();
+                    } else {
+                        ctxt.getRuntimeContext().makeYoungest(ticket);
+                    }
+                }
+            }
+            /*
+             * (4) Service request
              */
             if (theServlet instanceof SingleThreadModel) {
                // sync on the wrapper so that the freshness
@@ -386,14 +395,6 @@ public class JspServletWrapper {
             } else {
                 theServlet.service(request, response);
             }
-            if (options.getMaxLoadedJsps() > 0) {
-                synchronized(this) {
-                    if (ticket == null)
-                        ticket = ctxt.getRuntimeContext().push(this);
-                    else
-                        ctxt.getRuntimeContext().makeYoungest(ticket);
-                }
-            }
         } catch (UnavailableException ex) {
             String includeRequestUri = (String)
                 request.getAttribute("javax.servlet.include.request_uri");