Skip to main content

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [List Home]
Re: [jetty-users] problem with continuation reuse - how to sync timeout with async task?

Thanks for your response. This would mean I had to keep track of all background task and make some kind of syncronization between the servlet and the background task what is something I would avoid! Would it then be safe to acces the state of a Continuation from different threads while in the web-cycle?

Am 03.11.2014 18:01, schrieb Simone Bordet:

On Mon, Nov 3, 2014 at 1:51 PM, Christoph Läubrich
<laeubi@xxxxxxxxxxxxxx>  wrote:
I'm using jetty-8 (embedded) and have a servlet that upon request starts
some (lengthy) computation in the background and wants to return this to the
user after completion.
I try to use the
(even though the problem will exits also with suspend/resume).
The problem occurs when I set a timeout (I just want the task to wait a
certian amaount of time for completion and cancel it then):

If the continuation times out I send an error back to the client (see code
below), but my async task still holds a reference to the continuation. Since
jetty reuses the continuation object after timeout, when the task now
finished and tries to contine the continuation I get problems since
   a) The continuation is reused but for a completely different request
   b) The continuation is reused but not reasigend yet
When the continuation expires, you should set a flag to your
background task to *not* use the continuation, since the response has
already been sent.

Back to the top