AsyncContext.get[Request|Response] cannot be called after dispatch()
- Dominant language
- Java
- Stars
- 4.1k
- Forks
- 2k
- Avg merge
- 3d 56m
- Merged PRs (30d)
- 48
Description
migrated from Bugzilla [#441390](https://bugs.eclipse.org/bugs/show_bug.cgi?id=441390)
status ASSIGNED severity _normal_ in component _server_ for _9.2.x_
Reported in version _9.2.2_ on platform _PC_
Assigned to: Greg Wilkins
On 2014-08-07 17:33:52 -0400, Simone Bordet wrote:
> The javadocs for those 2 methods in JEE 7 has been "enhanced" with the requirement of throwing an IllegalStateException: http://docs.oracle.com/javaee/7/api/javax/servlet/AsyncContext.html#getRequest%28%29
>
> By contract JEE 6 did not have this clause.
>
> We should probably enforce this behavior, because it's quite common to call these methods after a dispatch(), and if Jetty allows it, applications won't be portable.
On 2014-08-07 20:04:15 -0400, Greg Wilkins wrote:
> Hmmm we already had some ISE code, but it waits until the servlet dispatch cycle has completed. Will toughen it up a bit... but have also raised https://java.net/jira/browse/SERVLET_SPEC-103
On 2014-08-07 21:23:04 -0400, Greg Wilkins wrote:
> I'm not going to make any changes until I hear back from SPEC-103
>
> We gave a use-case where we log the request in an onComplete callback as follows:
>
> ```
> @Override
> public void onComplete(AsyncEvent event) throws IOException
> {
> AsyncContextState context = (AsyncContextState)event.getAsyncContext();
> Request request=context.getHttpChannelState().getBaseRequest();
> Response response=request.getResponse();
> _requestLog.log(request,response);
> }
> ```
>
> If getRequest throws an ISE after dispatch, then this does not work.
Contributor guide
Assessment
This issue has not been assessed yet.