[jsr369-experts] Calling complete with write pending

From: Greg Wilkins <gregw_at_webtide.com>
Date: Fri, 27 Nov 2015 10:16:21 +1100

For the complete method we still say:

"It is legal to call this [complete] method anytime after a call to
ServletRequest.startAsync() or
ServletRequest.startAsync(ServletRequest, ServletResponse)
and before a call to one of the dispatch methods."

But that text was written before we added the async IO API which has
introduced the ability to have statefulness like write/read callbacks

So for example if an app has done a write(...), then called isReady(),
which has returned false, is it still OK to call complete()?

Jetty's interpretation is no. a call to complete has an implicit write
operation (flush buffers and/or send the last chunk). That write cannot be
done until the pending write is complete. Furthermore, if we do call
complete when isReady() is false, we are in a race with a potential onError

Thus I think that complete method can only be called in async IO mode if
the write site isReady() method returns true.


Greg Wilkins <gregw@webtide.com> CTO http://webtide.com