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?


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.

Simone Bordet
Developer advice, training, services and support
from the Jetty & CometD experts.
Intalio, the modern way to build business applications.

Back to the top