Uploaded image for project: 'Camel'
  1. Camel
  2. CAMEL-12264

Concurrent modification in safeCopyProperties Method of DefaultExchange

    XMLWordPrintableJSON

Details

    • Bug
    • Status: Resolved
    • Minor
    • Resolution: Cannot Reproduce
    • 2.20.2
    • None
    • camel-core
    • None
    • Unknown

    Description

      safeCopyProperties method  of DefaultExchange class,

      // new LinkedList<>(Collection c) is not thread-safe.
      answer.put(Exchange.MESSAGE_HISTORY, new LinkedList<>(history));
      


      new LinkedList<>(Collection c) is not thread-safe. Quote from LinkedList implementation "The behavior of this operation is undefined if the specified collection is modified while the operation is in
      progress."

       

       In our case, when we have high throughput, we see the following exception (when the history is concurrently being modified.):

      java.lang.ArrayIndexOutOfBoundsException: 19
              at java.util.LinkedList.toArray(LinkedList.java:1053)
              at java.util.LinkedList.addAll(LinkedList.java:408)
              at java.util.LinkedList.addAll(LinkedList.java:387)
              at java.util.LinkedList.<init>(LinkedList.java:119)
              at org.apache.camel.impl.DefaultExchange.safeCopyProperties(DefaultExchange.java:152)
              at org.apache.camel.impl.DefaultExchange.copy(DefaultExchange.java:97)
              at org.apache.camel.util.ExchangeHelper.createCorrelatedCopy(ExchangeHelper.java:235)
              at org.apache.camel.util.ExchangeHelper.createCorrelatedCopy(ExchangeHelper.java:218)
              at org.apache.camel.processor.OnCompletionProcessor.prepareExchange(OnCompletionProcessor.java:190)
              at org.apache.camel.processor.OnCompletionProcessor$OnCompletionSynchronizationAfterConsumer.onComplete(OnCompletionProcessor.java:235)
              at org.apache.camel.util.UnitOfWorkHelper.doneSynchronizations(UnitOfWorkHelper.java:104)
              at org.apache.camel.impl.DefaultUnitOfWork.done(DefaultUnitOfWork.java:229)
              at org.apache.camel.util.UnitOfWorkHelper.doneUow(UnitOfWorkHelper.java:65)

      Attachments

        Issue Links

          Activity

            People

              Unassigned Unassigned
              yifan.wu@live.com Yifan Wu
              Votes:
              0 Vote for this issue
              Watchers:
              2 Start watching this issue

              Dates

                Created:
                Updated:
                Resolved: