Port improved fix for bug 30949 to TC6.
authormarkt <markt@13f79535-47bb-0310-9956-ffa450edef68>
Wed, 5 Sep 2007 02:01:02 +0000 (02:01 +0000)
committermarkt <markt@13f79535-47bb-0310-9956-ffa450edef68>
Wed, 5 Sep 2007 02:01:02 +0000 (02:01 +0000)
git-svn-id: https://svn.apache.org/repos/asf/tomcat/tc6.0.x/trunk@572856 13f79535-47bb-0310-9956-ffa450edef68

java/org/apache/catalina/core/ApplicationDispatcher.java
webapps/docs/changelog.xml

index 4053a46..47ae0c7 100644 (file)
@@ -341,10 +341,6 @@ final class ApplicationDispatcher
             wrequest.setQueryString(hrequest.getQueryString());
 
             processRequest(request,response,state);
-
-            wrequest.recycle();
-            unwrapRequest(state);
-
         }
 
         // Handle an HTTP path-based forward
@@ -377,10 +373,6 @@ final class ApplicationDispatcher
             }
 
             processRequest(request,response,state);
-
-            wrequest.recycle();
-            unwrapRequest(state);
-
         }
 
         // This is not a real close in order to support error processing
@@ -521,8 +513,6 @@ final class ApplicationDispatcher
                     ApplicationFilterFactory.DISPATCHER_REQUEST_PATH_ATTR,
                     servletPath);
             invoke(state.outerRequest, state.outerResponse, state);
-
-            wrequest.recycle();
         }
 
         // Handle an HTTP path based include
@@ -555,8 +545,6 @@ final class ApplicationDispatcher
                     ApplicationFilterFactory.DISPATCHER_REQUEST_PATH_ATTR,
                     servletPath);
             invoke(state.outerRequest, state.outerResponse, state);
-
-            wrequest.recycle();
         }
 
     }
@@ -731,7 +719,9 @@ final class ApplicationDispatcher
         // See Bugzilla 30949
         unwrapRequest(state);
         unwrapResponse(state);
-
+        // Recycle request if necessary (also BZ 30949)
+        recycleRequestWrapper(state);
+        
         // Rethrow an exception if one was thrown by the invoked servlet
         if (ioException != null)
             throw ioException;
@@ -986,4 +976,9 @@ final class ApplicationDispatcher
                     "applicationDispatcher.specViolation.response"));
         }
     }
+
+    private void recycleRequestWrapper(State state) {
+        if (state.wrapRequest instanceof ApplicationHttpRequest) {
+            ((ApplicationHttpRequest) state.wrapRequest).recycle();        }
+    }
 }
index afd0854..e77fe4b 100644 (file)
   <subsection name="Catalina">
     <changelog>
       <fix>
+        <bug>30949</bug>: Improve previous fix. Ensure requests are re-cycled
+        on cross-context includes and forwards when an exception occurs in the
+        target page. (markt)
+      </fix>
+      <fix>
         <bug>42944</bug>: Correctly handle servlet mappings that use a '+'
         character as part of the url pattern. (markt)
       </fix>