vmassol     2003/07/14 01:17:26

  Modified:    framework/src/java/share/org/apache/cactus/server
                        RequestDispatcherWrapper.java
  Log:
  Perform check to prevent ClassCastException and to display a more friendly error 
message...
  
  Revision  Changes    Path
  1.2       +22 -1     
jakarta-cactus/framework/src/java/share/org/apache/cactus/server/RequestDispatcherWrapper.java
  
  Index: RequestDispatcherWrapper.java
  ===================================================================
  RCS file: 
/home/cvs/jakarta-cactus/framework/src/java/share/org/apache/cactus/server/RequestDispatcherWrapper.java,v
  retrieving revision 1.1
  retrieving revision 1.2
  diff -u -r1.1 -r1.2
  --- RequestDispatcherWrapper.java     13 Jul 2003 22:06:01 -0000      1.1
  +++ RequestDispatcherWrapper.java     14 Jul 2003 08:17:25 -0000      1.2
  @@ -100,6 +100,16 @@
       public void forward(ServletRequest theRequest, ServletResponse theResponse)
           throws IOException, ServletException
       {
  +        // If the request is not our request wrapper, then someone is doing
  +        // something wrong!
  +        if (!HttpServletRequestWrapper.class.isAssignableFrom(
  +            theRequest.getClass()))
  +        {
  +             throw new ServletException("The request object passed to "
  +                + "forward() must be the request object you got from your "
  +                + "Cactus test case (i.e. a Cactus request wrapper object). "
                + "Instead we got [" + theRequest.getClass().getName() + "]");
  +        }       
  +
           HttpServletRequestWrapper request = 
               (HttpServletRequestWrapper) theRequest;
   
  @@ -120,6 +130,17 @@
       public void include(ServletRequest theRequest, ServletResponse theResponse)
           throws IOException, ServletException
       {
  +        // If the request is not our request wrapper, then someone is doing
  +        // something wrong!
  +        if (!HttpServletRequestWrapper.class.isAssignableFrom(
  +            theRequest.getClass()))
  +        {
  +             throw new ServletException("The request object passed to "
  +                + "include() must be the request object you got from your "
  +                + "Cactus test case (i.e. a Cactus request wrapper object). "
  +                + "Instead we got [" + theRequest.getClass().getName() + "]");
  +        }       
  +
           HttpServletRequestWrapper request = 
               (HttpServletRequestWrapper) theRequest;
   
  
  
  

---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to