Camel
  1. Camel
  2. CAMEL-4264

The routeContext stack of DefaultUnitOfWork should be thread safe

    Details

    • Type: Bug Bug
    • Status: Resolved
    • Priority: Major Major
    • Resolution: Fixed
    • Affects Version/s: 2.7.3, 2.8.0
    • Fix Version/s: 2.8.1, 2.9.0
    • Component/s: camel-core
    • Labels:
      None

      Description

      Here is the stack trace

      java.util.EmptyStackException
              at java.util.Stack.peek(Stack.java:85)
              at java.util.Stack.pop(Stack.java:67)
              at 
      org.apache.camel.impl.DefaultUnitOfWork.popRouteContext(DefaultUnitOfWork.java:226)
              at 
      org.apache.camel.processor.DefaultChannel$1.done(DefaultChannel.java:260)
              at 
      org.apache.camel.processor.RedeliveryErrorHandler.processErrorHandler(RedeliveryErrorHandler.java:330)
              at 
      org.apache.camel.processor.RedeliveryErrorHandler.process(RedeliveryErrorHandler.java:208)
              at 
      org.apache.camel.processor.DefaultChannel.process(DefaultChannel.java:256)
              at 
      org.apache.camel.util.AsyncProcessorHelper.process(AsyncProcessorHelper.java:70)
              at org.apache.camel.processor.Pipeline.process(Pipeline.java:143)
              at org.apache.camel.processor.Pipeline.process(Pipeline.java:78)
              at 
      org.apache.camel.processor.UnitOfWorkProcessor.process(UnitOfWorkProcessor.java:113)
              at 
      org.apache.camel.util.AsyncProcessorHelper.process(AsyncProcessorHelper.java:91)
              at 
      org.apache.camel.processor.DelegateAsyncProcessor.process(DelegateAsyncProcessor.java:85)
              at 
      org.apache.camel.processor.aggregate.AggregateProcessor$1.run(AggregateProcessor.java:397)
              at 
      java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:441)
              at 
      java.util.concurrent.FutureTask$Sync.innerRun(FutureTask.java:303)
              at java.util.concurrent.FutureTask.run(FutureTask.java:138)
              at 
      java.util.concurrent.ThreadPoolExecutor$Worker.runTask(ThreadPoolExecutor.java:886)
              at 
      java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:908)
              at java.lang.Thread.run(Thread.java:619)
      
      

      You can find more information in this mail thread[1]
      [1]http://camel.465427.n5.nabble.com/EmptyStackException-in-DefaultUnitOfWork-popRouteContext-td4630106.html

        Issue Links

          Activity

          Hide
          Christian Müller added a comment -

          I saw this exception also from time to time in Camel 2.3.0, only when we enable tracing on the Camel context.

          Show
          Christian Müller added a comment - I saw this exception also from time to time in Camel 2.3.0, only when we enable tracing on the Camel context.
          Hide
          Willem Jiang added a comment -

          Applied patch into trunk.

          Show
          Willem Jiang added a comment - Applied patch into trunk.
          Hide
          Mitko Kolev added a comment -

          Hi Willem,
          is it really necessary to synchronize on the routeContext param
          in

          public void pushRouteContext(RouteContext routeContext)

          ?

          There are also other synchronization issues that concern the other memeber variables of the class, (e.g. synchronizations and subUnitOfWorks). Is synchrnonization really (not)needed for those memebers?

          Show
          Mitko Kolev added a comment - Hi Willem, is it really necessary to synchronize on the routeContext param in public void pushRouteContext(RouteContext routeContext) ? There are also other synchronization issues that concern the other memeber variables of the class, (e.g. synchronizations and subUnitOfWorks ). Is synchrnonization really (not)needed for those memebers?
          Hide
          Matthias Schmidt added a comment -

          Hi Willem, could you please add the number 2.5.0 to the list of affected versions?

          Show
          Matthias Schmidt added a comment - Hi Willem, could you please add the number 2.5.0 to the list of affected versions?
          Hide
          Christian Müller added a comment -

          pushRouteContext() should also synchronize on routeContextStack instead of routeContext. Thanks Matthias for pointing this out.

          Show
          Christian Müller added a comment - pushRouteContext() should also synchronize on routeContextStack instead of routeContext. Thanks Matthias for pointing this out.
          Hide
          Christian Müller added a comment -

          Committed r1151054
          Thanks Matthias for pointing this out.

          Show
          Christian Müller added a comment - Committed r1151054 Thanks Matthias for pointing this out.
          Hide
          Christian Müller added a comment -

          Added to the 2.9.0 release notes

          Show
          Christian Müller added a comment - Added to the 2.9.0 release notes
          Hide
          David Tombs added a comment -

          This issue is biting my organization hard in a critical route where we can't drop any messages. Would it be possible to target this for 2.8.1 or some kind of bugfix release? Thanks.

          Show
          David Tombs added a comment - This issue is biting my organization hard in a critical route where we can't drop any messages. Would it be possible to target this for 2.8.1 or some kind of bugfix release? Thanks.
          Hide
          Willem Jiang added a comment -

          Merged the patch into camel 2.8.x branch.

          Show
          Willem Jiang added a comment - Merged the patch into camel 2.8.x branch.
          Hide
          David Tombs added a comment -

          Excellent, thank you!

          Show
          David Tombs added a comment - Excellent, thank you!

            People

            • Assignee:
              Christian Müller
              Reporter:
              Willem Jiang
            • Votes:
              3 Vote for this issue
              Watchers:
              4 Start watching this issue

              Dates

              • Created:
                Updated:
                Resolved:

                Development