You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@tomcat.apache.org by "Bognár, Attila" <at...@netalfa.com> on 2003/04/20 18:43:03 UTC

ErrorReportValve casting bug?

hello,

in the source of ErrorReportValve:

     public void invoke(Request request, Response response,
                        ValveContext context)
         throws IOException, ServletException {

         // Perform the request
         context.invokeNext(request, response);

         ServletRequest sreq = (ServletRequest) request;
         Throwable throwable =
             (Throwable) sreq.getAttribute(Globals.EXCEPTION_ATTR);

         ServletResponse sresp = (ServletResponse) response;
...

how legal are the two castings? ((ServletRequest) request at line 174 and
(ServletResponse) response). I think not at all. There should be instead:
request.getRequest(), since it should not be expected that a Request is
also a ServletRequest.

attila

ps: I am writing a custom valve, where I make a wrapper request which does
not implement ServletRequest (why should it?), so there is a
ClassCastException. If I don't wrap it, it's a CoyoteRequest which
implements the ServletRequest interface, too, so there is no casting
exception.






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