tomcat-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From fha...@apache.org
Subject svn commit: r477737 - /tomcat/tc6.0.x/trunk/java/org/apache/catalina/core/ApplicationDispatcher.java
Date Tue, 21 Nov 2006 16:35:19 GMT
Author: fhanik
Date: Tue Nov 21 08:35:19 2006
New Revision: 477737

URL: http://svn.apache.org/viewvc?view=rev&rev=477737
Log:
Fix the logic of the checkSameObjects method.
The method did not take into account that the lastServiceRequest/Response could be wrapped
themselves.


Modified:
    tomcat/tc6.0.x/trunk/java/org/apache/catalina/core/ApplicationDispatcher.java

Modified: tomcat/tc6.0.x/trunk/java/org/apache/catalina/core/ApplicationDispatcher.java
URL: http://svn.apache.org/viewvc/tomcat/tc6.0.x/trunk/java/org/apache/catalina/core/ApplicationDispatcher.java?view=diff&rev=477737&r1=477736&r2=477737
==============================================================================
--- tomcat/tc6.0.x/trunk/java/org/apache/catalina/core/ApplicationDispatcher.java (original)
+++ tomcat/tc6.0.x/trunk/java/org/apache/catalina/core/ApplicationDispatcher.java Tue Nov
21 08:35:19 2006
@@ -969,10 +969,8 @@
     }
 
     private void checkSameObjects() throws ServletException {
-        ServletRequest originalRequest =
-            ApplicationFilterChain.getLastServicedRequest();
-        ServletResponse originalResponse =
-            ApplicationFilterChain.getLastServicedResponse();
+        ServletRequest originalRequest = ApplicationFilterChain.getLastServicedRequest();
+        ServletResponse originalResponse = ApplicationFilterChain.getLastServicedResponse();
         
         // Some forwards, eg from valves will not set original values 
         if (originalRequest == null || originalResponse == null) {
@@ -982,41 +980,47 @@
         boolean same = false;
         ServletRequest dispatchedRequest = appRequest;
         
+        //find the bottom most request, the one that was passed into the service method
+        while ( originalRequest instanceof ServletRequestWrapper && ((ServletRequestWrapper)
originalRequest).getRequest()!=null ) {
+            originalRequest = ((ServletRequestWrapper) originalRequest).getRequest();
+        }
+        //compare with the dispatched request
         while (!same) {
             if (originalRequest.equals(dispatchedRequest)) {
                 same = true;
             }
             if (!same && dispatchedRequest instanceof ServletRequestWrapper) {
-                dispatchedRequest =
-                    ((ServletRequestWrapper) dispatchedRequest).getRequest();
+                dispatchedRequest = ((ServletRequestWrapper) dispatchedRequest).getRequest();
             } else {
                 break;
             }
         }
         if (!same) {
-            throw new ServletException(sm.getString(
-                    "applicationDispatcher.specViolation.request"));
+            throw new ServletException(sm.getString("applicationDispatcher.specViolation.request"));
         }
         
         same = false;
         ServletResponse dispatchedResponse = appResponse;
         
+        //find the bottom most response, the one that was passed into the service method
+        while ( originalResponse instanceof ServletResponseWrapper && ((ServletResponseWrapper)
originalResponse).getResponse()!=null ) {
+            originalResponse = ((ServletResponseWrapper) originalResponse).getResponse();
+        }
+        //compare with the dispatched response
         while (!same) {
             if (originalResponse.equals(dispatchedResponse)) {
                 same = true;
             }
             
             if (!same && dispatchedResponse instanceof ServletResponseWrapper) {
-                dispatchedResponse =
-                    ((ServletResponseWrapper) dispatchedResponse).getResponse();
+                dispatchedResponse = ((ServletResponseWrapper) dispatchedResponse).getResponse();
             } else {
                 break;
             }
         }
 
         if (!same) {
-            throw new ServletException(sm.getString(
-                    "applicationDispatcher.specViolation.response"));
+            throw new ServletException(sm.getString("applicationDispatcher.specViolation.response"));
         }
     }
 }



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


Mime
View raw message