jakartaee / jakartaee/servlet

AsyncContext ISE inconsistency

Open
#103 6 comments 0 reactions 1 assignee Claimed by @glassfishrobot View on GitHub
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

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.