You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@camel.apache.org by Thibaut Robert <th...@gmail.com> on 2015/10/08 15:54:57 UTC

ConcurrentModificationException on seda consumer

Hi,

I have a simple route consuming from a seda and sending to an akka Actor
(with akka-camel).
On heavy load, I got the following error:

java.util.ConcurrentModificationException: null
at java.util.TreeMap$PrivateEntryIterator.nextEntry(TreeMap.java:1207)
~[na:1.8.0_45-internal]
at java.util.TreeMap$EntryIterator.next(TreeMap.java:1243)
~[na:1.8.0_45-internal]
at java.util.TreeMap$EntryIterator.next(TreeMap.java:1238)
~[na:1.8.0_45-internal]
at java.util.TreeMap.buildFromSorted(TreeMap.java:2555)
~[na:1.8.0_45-internal]
at java.util.TreeMap.buildFromSorted(TreeMap.java:2504)
~[na:1.8.0_45-internal]
at java.util.TreeMap.putAll(TreeMap.java:319) ~[na:1.8.0_45-internal]
at org.apache.camel.impl.MessageSupport.copyFrom(MessageSupport.java:151)
~[camel-core-2.15.3.jar:2.15.3]
at org.apache.camel.impl.MessageSupport.copy(MessageSupport.java:124)
~[camel-core-2.15.3.jar:2.15.3]
at
org.apache.camel.component.seda.SedaConsumer.doRun(SedaConsumer.java:203)
[camel-core-2.15.3.jar:2.15.3]
at org.apache.camel.component.seda.SedaConsumer.run(SedaConsumer.java:147)
[camel-core-2.15.3.jar:2.15.3]
at
java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142)
[na:1.8.0_45-internal]
at
java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617)
[na:1.8.0_45-internal]
at java.lang.Thread.run(Thread.java:745) [na:1.8.0_45-internal]

Looking at the source of SedaConsumer, I suspect an issue with this code
(line 197-206):

                        // send a new copied exchange with new camel context
                        Exchange newExchange = prepareExchange(exchange);
                        // process the exchange
                        sendToConsumers(newExchange);
                        // copy the message back
                        if (newExchange.hasOut()) {
                            exchange.setOut(newExchange.getOut().copy());
                        } else {
                            exchange.setIn(newExchange.getIn());
                        }

sendToConsumers will not block if the route is asynchronous (which is my
case). The copy of the out message is done concurrently while the message
is processing.

Is it a bug or am i missing something ?

Thanks,
Thibaut