IllegalStateException in CamelContinuationServlet under heavy load
------------------------------------------------------------------

                 Key: CAMEL-2986
                 URL: https://issues.apache.org/activemq/browse/CAMEL-2986
             Project: Apache Camel
          Issue Type: Bug
          Components: camel-jetty
    Affects Versions: 2.4.0
            Reporter: Martin Krasser
            Assignee: Martin Krasser
             Fix For: 2.5.0


Reason is a race between continuation.suspend() and continuation.resume(). It 
can occur that continuation.resume() is executed before continuation.suspend() 
leading to an IllegalStateException thrown by Jetty:

{noformat}
java.lang.IllegalStateException: DISPATCHED,initial
    at 
org.eclipse.jetty.server.AsyncContinuation.dispatch(AsyncContinuation.java:364)
    at 
org.eclipse.jetty.server.AsyncContinuation.resume(AsyncContinuation.java:769)
    at 
org.apache.camel.component.jetty.CamelContinuationServlet$1.done(CamelContinuationServlet.java:85)
    at 
org.apache.camel.management.InstrumentationProcessor$1.done(InstrumentationProcessor.java:78)
    at 
org.apache.camel.processor.UnitOfWorkProcessor$1.done(UnitOfWorkProcessor.java:104)
    at org.apache.camel.processor.DefaultChannel$1.done(DefaultChannel.java:262)
    at 
org.apache.camel.processor.RedeliveryErrorHandler$1.done(RedeliveryErrorHandler.java:302)
    at 
org.apache.camel.management.InstrumentationProcessor$1.done(InstrumentationProcessor.java:78)
    at 
org.apache.camel.management.InstrumentationProcessor$1.done(InstrumentationProcessor.java:78)
{noformat}

This is the case when an async completion callback is faster than the thread 
that is concurrently executing the {{if (continuation.isInitial())}} block. 

I'll commit a fix soon that also follows the recommendations in 
http://wiki.eclipse.org/Jetty/Feature/Continuations to always call 
continuation.suspend() before registering the continuation with a callback 
handler.


-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.

Reply via email to