users@servlet-spec.java.net

[servlet-spec users] [jsr369-experts] Clarification of threading requirements of section 6.2.3

From: Mark Thomas <markt_at_apache.org>
Date: Sat, 06 Dec 2014 00:14:51 +0000

Hi,

Section 6.2.3 includes the following text:
<quote>
A Filter and the target servlet or resource at the end of the filter
chain must execute in the same invocation thread.
</quote>

As a result of a bug raised against Apache Tomcat [1] I am seeking
clarification of the meaning of that sentence.

As written, the meaning seems unambiguous. However, does it apply when
the request is in asynchronous mode? To put it another way is the
following legal?
- filter calls ServletRequest.startAsync()
- filter calls AsyncContext.start(Runnable)
- That Runnable called FilterChain.doFilter()

If the above were legal it creates some implementation issues for the
containers but they are not insurmountable. Clearly there is a user
requirement to do this else the bug would not have been raised.

Looking back at the original discussion that led to this text being
added, async behaviour was not considered.

So is the above legal, in which case we need to clarify 6.2.3 or is it
illegal? I'm currently leaning towards it being legal.

Mark


[1] https://issues.apache.org/bugzilla/show_bug.cgi?id=57284