tomcat-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Bognár, Attila" <attila.bog...@netalfa.com>
Subject ErrorReportValve casting bug?
Date Sun, 20 Apr 2003 16:43:03 GMT

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


Mime
View raw message