I was able to reproduce and debug the issue. I think there is a Jetty
issue. If asyncContext.dispatch() is invoked quickly before the initial
request processing thread has exited, the dispatch is held as it should be,
but request.isAsyncStarted returns (incorrectly) false, so remaining code
on the initial request processing thread doesn't realize the async
processing has started.

Not sure if it matters but in such cases I do see calls to
Response.getOutputStream() from within Jetty. Here is a sample stack trace:

Response.getOutputStream() line: 700
ErrorPageErrorHandler(ErrorHandler).handle(String, Request,
HttpServletRequest, HttpServletResponse) line: 69
ErrorPageErrorHandler.handle(String, Request, HttpServletRequest,
HttpServletResponse) line: 159
Response.sendError(int, String) line: 387
Response.sendError(int) line: 339
ServletHandler.doHandle(String, Request, HttpServletRequest,
HttpServletResponse) line: 582
ServletHandler(ScopedHandler).handle(String, Request, HttpServletRequest,
HttpServletResponse) line: 138
ConstraintSecurityHandler(SecurityHandler).handle(String, Request,
HttpServletRequest, HttpServletResponse) line: 540
SessionHandler.doHandle(String, Request, HttpServletRequest,
HttpServletResponse) line: 213
WebAppContext(ContextHandler).doHandle(String, Request, HttpServletRequest,
HttpServletResponse) line: 1094
ServletHandler.doScope(String, Request, HttpServletRequest,
HttpServletResponse) line: 432
SessionHandler.doScope(String, Request, HttpServletRequest,
HttpServletResponse) line: 175
WebAppContext(ContextHandler).doScope(String, Request, HttpServletRequest,
HttpServletResponse) line: 1028
WebAppContext(ScopedHandler).handle(String, Request, HttpServletRequest,
HttpServletResponse) line: 136
ContextHandlerCollection.handle(String, Request, HttpServletRequest,
HttpServletResponse) line: 258
HandlerCollection.handle(String, Request, HttpServletRequest,
HttpServletResponse) line: 109
RewriteHandler(HandlerWrapper).handle(String, Request, HttpServletRequest,
HttpServletResponse) line: 97
RewriteHandler.handle(String, Request, HttpServletRequest,
HttpServletResponse) line: 317
Server(HandlerWrapper).handle(String, Request, HttpServletRequest,
HttpServletResponse) line: 97
Server.handle(HttpChannel<?>) line: 445
HttpConnection$HttpChannelOverHttp(HttpChannel<T>).handle() line: 267
HttpConnection.onFillable() line: 224
AbstractConnection$ReadCallback.run() line: 358
QueuedThreadPool.runJob(Runnable) line: 601
QueuedThreadPool$3.run() line: 532
Thread.run() line: 722

After all that the dispatch is executed still and calls to
servletResponse.getWriter() fail with the originally reported
"IllegalStateException: STREAM".

Rossen
_______________________________________________
jetty-users mailing list
[email protected]
https://dev.eclipse.org/mailman/listinfo/jetty-users

Reply via email to