Skip to main content

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [List Home]
[servlet-dev] AsyncContext.complete() whilst red/write blocked


We've had a report of the following behaviour from JBoss Resteasy:
  1. servlet calls `request.startAsync()` and then starts 2 non container threads before returning.
  2. Thread-A blocks in a call to `request.getInputStream().read()`
  3. Thread-B calls `asyncContext.complete()`
Because there is no container thread dispatched to the app, the handling of `complete()` can start straight away.  But what should be done with the blocked read?

Perhaps the blocked read should throw an IOexception, but then the app might catch it and start operating on the request/response, which may be recycled to have been reused.

So is it an error to call `complete()` in this way?   The spec says that request/response are not thread safe in general, so is having 2 threads operating on them in this way supported?   Shouldn't the app be required to make sure other threads have stopped operating on the request/response before doing a complete?   So complete could throw an ISE in this circumstance.

thoughts?

--

Back to the top