On 19/12/2014 03:23, Shing Wai Chan wrote:
> Let me try to summarize the discussion.
>
> 1. There is a concern on whether FilterChain#doFilter can be called by a
> thread other than the container invocation thread.
> Similar question for RequestDispatcher#dispatch.
> 2. What is the return values of #getContextPath, #getServletPath,
> #getPathInfo in case of async?
>
>
> For (1),
> From Servlet 3.1: A Filter and the target servlet or resource at the end
> of the filter chain must execute in the same invocation thread.
> This implicitly implies that FilterChain#doFilter should not be called
> by a thread other than the container invocation thread.
> We would like to make this more explicit in the spec by adding the
> following in javadoc of FilterChain#doFilter
> @throw IllegalStateException if it is invoked by a thread other
> than the container invocation thread
>
> Any comments?
I agree that this would make the specification clearer in this area.
However, I don't see why we have this restriction in the first place. As
I have stated elsewhere on this thread, no explanation was given when
this restriction was introduced and right now I don't see why we need it
for sync or async.
The original use case [1] that triggered this thread looks reasonable
and I'd like to support it if possible. The clarification proposed above
would not allow the use case to be supported.
Regarding 2) my current thinking is that the return values are as they
were for the request/response at the point async was started and remain
unchanged until the async request is dispatched at which point they
change to reflect the target of the dispatch. It is TBD if some
mechanism is provided along the lines of 9.4.2 to expose some of the
original (remembering there may be multiple async/dispatch sequences)
values.
Mark
[1]
https://issues.apache.org/bugzilla/show_bug.cgi?id=57284