tomcat-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From p...@apache.org
Subject svn commit: r545127 - in /tomcat/container/tc5.5.x: catalina/src/share/org/apache/catalina/core/ApplicationDispatcher.java webapps/docs/changelog.xml
Date Thu, 07 Jun 2007 09:34:01 GMT
Author: pero
Date: Thu Jun  7 02:33:59 2007
New Revision: 545127

URL: http://svn.apache.org/viewvc?view=rev&rev=545127
Log:
Fix correct ApplicationDispatcher forward/include handling after an exception is thrown. This
patch fix a memory leak
as <code>STRICT_SERVLET_COMPLIANCE</code> system property is enabled and that
cluster  crossContext session replication
working correct after an exception is thrown at a RequestDispatcher.forward/include call.
But I don't really like this double try/catch implementation ;-(


Modified:
    tomcat/container/tc5.5.x/catalina/src/share/org/apache/catalina/core/ApplicationDispatcher.java
    tomcat/container/tc5.5.x/webapps/docs/changelog.xml

Modified: tomcat/container/tc5.5.x/catalina/src/share/org/apache/catalina/core/ApplicationDispatcher.java
URL: http://svn.apache.org/viewvc/tomcat/container/tc5.5.x/catalina/src/share/org/apache/catalina/core/ApplicationDispatcher.java?view=diff&rev=545127&r1=545126&r2=545127
==============================================================================
--- tomcat/container/tc5.5.x/catalina/src/share/org/apache/catalina/core/ApplicationDispatcher.java
(original)
+++ tomcat/container/tc5.5.x/catalina/src/share/org/apache/catalina/core/ApplicationDispatcher.java
Thu Jun  7 02:33:59 2007
@@ -336,7 +336,11 @@
         HttpServletResponse hresponse = null;
         if (response instanceof HttpServletResponse)
             hresponse = (HttpServletResponse) response;
-
+        
+        IOException ioException = null;
+        ServletException servletException = null;
+        RuntimeException runtimeException = null;
+        
         // Handle a non-HTTP forward by passing the existing request/response
         if ((hrequest == null) || (hresponse == null)) {
 
@@ -361,11 +365,19 @@
             wrequest.setPathInfo(hrequest.getPathInfo());
             wrequest.setQueryString(hrequest.getQueryString());
 
-            processRequest(request,response,state);
-
-            wrequest.recycle();
-            unwrapRequest(state);
-
+            try {
+                processRequest(request,response,state);
+            } catch ( ServletException sexp) {
+                servletException = sexp ;
+            } catch ( IOException iexp) {
+                ioException = iexp ;
+            } catch ( RuntimeException rexp) {
+                runtimeException = rexp ;
+            } finally {
+                wrequest.recycle();
+                // is called at invoke
+                // unwrapRequest(state);
+            }
         }
 
         // Handle an HTTP path-based forward
@@ -399,11 +411,19 @@
                 wrequest.setQueryString(queryString);
                 wrequest.setQueryParams(queryString);
             }
-
-            processRequest(request,response,state);
-
-            wrequest.recycle();
-            unwrapRequest(state);
+            try { 
+                processRequest(request,response,state);
+            } catch ( ServletException sexp) {
+                servletException = sexp ;
+            } catch ( IOException iexp) {
+                ioException = iexp ;
+            } catch ( RuntimeException rexp) {
+                runtimeException = rexp ;
+            } finally {
+                wrequest.recycle();
+                // is called at invoke
+                // unwrapRequest(state);
+            }
 
         }
 
@@ -439,6 +459,14 @@
             }
         }
 
+        // Rethrow an exception if one was thrown by the invoked servlet
+        if (ioException != null)
+            throw ioException;
+        if (servletException != null)
+            throw servletException;
+        if (runtimeException != null)
+            throw runtimeException;
+
     }
 
     
@@ -553,9 +581,12 @@
             wrequest.setAttribute(
                     ApplicationFilterFactory.DISPATCHER_REQUEST_PATH_ATTR,
                     servletPath);
-            invoke(state.outerRequest, state.outerResponse, state);
-
-            wrequest.recycle();
+            try {
+                invoke(state.outerRequest, state.outerResponse, state);
+            } finally {
+                wrequest.recycle();
+            }
+            
         }
 
         // Handle an HTTP path based include
@@ -591,9 +622,11 @@
             wrequest.setAttribute(
                     ApplicationFilterFactory.DISPATCHER_REQUEST_PATH_ATTR,
                     servletPath);
-            invoke(state.outerRequest, state.outerResponse, state);
-
-            wrequest.recycle();
+            try {
+                invoke(state.outerRequest, state.outerResponse, state);
+            } finally {
+                wrequest.recycle();
+            }
         }
 
     }

Modified: tomcat/container/tc5.5.x/webapps/docs/changelog.xml
URL: http://svn.apache.org/viewvc/tomcat/container/tc5.5.x/webapps/docs/changelog.xml?view=diff&rev=545127&r1=545126&r2=545127
==============================================================================
--- tomcat/container/tc5.5.x/webapps/docs/changelog.xml (original)
+++ tomcat/container/tc5.5.x/webapps/docs/changelog.xml Thu Jun  7 02:33:59 2007
@@ -102,7 +102,12 @@
       </add>
       <add>
         And getSession() operation to StandardManager and DeltaManager JMX Interface (pero)
-      </add>     
+      </add>
+      <fix>
+         <bug>30949</bug>: Fix correct ApplicationDispatcher forward/include
handling after an exception is thrown. 
+         This patch fix a memory leak as <code>STRICT_SERVLET_COMPLIANCE</code>
system property is enabled and that cluster 
+         crossContext session replication working correct after an exception is thrown at
a RequestDispatcher.forward/include() call. (pero)
+      </fix>     
     </changelog>
   </subsection>
   <subsection name="Webapps">



---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@tomcat.apache.org
For additional commands, e-mail: dev-help@tomcat.apache.org


Mime
View raw message