Yifan Wu created CAMEL-12264:
--------------------------------
Summary: Concurrent modification in safeCopyProperties Method of
DefaultExchange
Key: CAMEL-12264
URL: https://issues.apache.org/jira/browse/CAMEL-12264
Project: Camel
Issue Type: Bug
Components: camel-core
Reporter: Yifan Wu
{color:#ffc66d}{color:#333333}safeCopyProperties method of DefaultExchange
class, {color}
{color}
{code:java}
// new LinkedList<>(Collection c) is not thread-safe.
answer.put(Exchange.MESSAGE_HISTORY, new LinkedList<>(history));
{code}
{color:#ffc66d}{color:#333333}new LinkedList<>(Collection c) is not
thread-safe. Quote from LinkedList implementation "{color}{color}
{color:#629755}The behavior of this operation is undefined if
{color}{color:#629755}* the specified collection is modified while the
operation is in
{color}{color:#629755}* progress."{color}
{color:#333333}In our case, when we have high throughput, we see the following
exception:
{color}
{color:#333333}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){color}
--
This message was sent by Atlassian JIRA
(v7.6.3#76005)