jsr340-experts@servlet-spec.java.net

[jsr340-experts] Non-blocking IO and async questions

From: Mark Thomas <markt_at_apache.org>
Date: Tue, 30 Apr 2013 10:58:05 +0100

I'm working on finishing off Tomcat's non-blocking implementation and
have come across the following scenarios that don't seem to be covered
by the specification. I have have missed something please feel free to
point me to the relevant part of the spec and/or Javadoc.

All these scenarios start with the following:

1. Application calls ServletRequest.startAsync()
2. Application calls ServletInputStream.setReadListener() and/or
ServletOutputStream.setWriteListener()

so we have an async request using non-blocking IO for input and/or output.


My questions are what happens if:

A.
The application starts a large async write and then calls
AsyncContext.complete() or AsyncContext.dispatch() before the write has
completed. Does this result in:
a) an error?
b) the delay of the complete() or dispatch() until the write has completed?
c) something else?

B.
The applications starts a large async read and then calls
AsyncContext.complete() or AsyncContext.dispatch() before all the data
has been read. Does this result in:
a) an error?
b) the delay of the complete() or dispatch() until all the data has been
read?
c) complete() and dispatch() are processed as soon as control returns to
the container and any unread data is available through the
ServletInputStream via a blocking read?
d) something else?


My working assumptions at this point are A b) and B c)

Cheers,

Mark