https://bz.apache.org/bugzilla/show_bug.cgi?id=66533

            Bug ID: 66533
           Summary: Wrapping Requests or Responses in Valves is not
                    possible
           Product: Tomcat 11
           Version: unspecified
          Hardware: PC
                OS: Linux
            Status: NEW
          Severity: normal
          Priority: P2
         Component: Catalina
          Assignee: dev@tomcat.apache.org
          Reporter: wolfg...@illmeyer.com
  Target Milestone: -------

The javadoc of org.apache.catalina.Valve.invoke(Request, Response) states:

> An individual Valve MAY perform the following actions, in the specified order:
> […]
> Examine the properties of the specified Request and Response, wrap either or
> both of these objects to supplement their functionality, and pass them on.

Due to the fact that that said method receives
org.apache.catalina.connector.Request and
org.apache.catalina.connector.Response, neither of which are interfaces, i
don't see how it would be possible to actually wrap either request or response
(at least without the developer resorting to ugly black-magic-type measures).

In fact, the argument classes implement HttpServletRequest and
HttpServletResponse, respectively, which would be much better suited for
creating wrappers (indeed javax.servlet.http.HttpServletRequestWrapper and so
on already exist)

I therefore suggest that, with Tomcat 11, the time has finally come to stop
mocking developers trying to implement actual functionality in Valves and
change the signature of Valve.invoke() to something like:

void invoke(HttpServletRequest, HttpServletResponse)

If I'm missing something from the Request and Response classes, that is
currently needed by the included Valves, maybe it could be passed as a third
argument of some new type ValveContext or similar. Another possibility would be
to extend HttpServletRequest and HttpServletResponse for those purposes, use
the resulting interfaces as argument types for the invoke() method and also
provide corresponding wrapper base classes.

-- 
You are receiving this mail because:
You are the assignee for the bug.
---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscr...@tomcat.apache.org
For additional commands, e-mail: dev-h...@tomcat.apache.org

Reply via email to