AsyncContext ISE inconsistency
- Dominant language
- Java
- Stars
- 325
- Forks
- 112
- PR merge metrics
- No merged PRs in 30d
Description
The javadoc for when AsyncContext should throw an ISE is inconsistent:
getRequest()
IllegalStateException - if complete() or any of the dispatch() methods has been called in the asynchronous cycle
addListener(...)
IllegalStateException - if this method is called after the container-initiated dispatch, during which one of the ServletRequest.startAsync() methods was called, has returned to the container
So getRequest fails with an ISE immediately after dispatch or complete have been called (even if called in another thread), while addListener waits until after the current dispatch returns before throwing any ISE.
These should be consistent, because a filter that is trying to add a Listener may need to call getRequest in order to obtain the wrapped request. Currently there is a race for such code that will fail if another thread calls dispatch/complete before the thread dispatched to the filters/servlet has returned.
Contributor guide
Assessment
This issue has not been assessed yet.