You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@camel.apache.org by "Claus Ibsen (JIRA)" <ji...@apache.org> on 2015/10/21 17:21:27 UTC

[jira] [Commented] (CAMEL-9237) ConcurrentModificationException when adding/removing routes in multiple threads

    [ https://issues.apache.org/jira/browse/CAMEL-9237?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=14967306#comment-14967306 ] 

Claus Ibsen commented on CAMEL-9237:
------------------------------------

Are you running a set of independent tests in parallel and for each test you add/remove routes dynamically, all on a single shared CamelContext ?
You are not able to use a private camel context per test so they run in isolation and can be safely parallelized?

But sure you are welcome to work on a patch about the ConcurrentModificationException. But mind that adding / removing routes takes a fair bit of logic so its not trivial to make it parallel.

> ConcurrentModificationException when adding/removing routes in multiple threads
> -------------------------------------------------------------------------------
>
>                 Key: CAMEL-9237
>                 URL: https://issues.apache.org/jira/browse/CAMEL-9237
>             Project: Camel
>          Issue Type: Bug
>          Components: camel-core, tests
>    Affects Versions: 2.16.0
>            Reporter: Chris Ribble
>            Priority: Minor
>
> Dynamically adding or removing routes in multiple threads can cause a ConcurrentModificationException. For example, in my project's tests, we dynamically mock out a large number of routes. When we run these tests serially it works fine, but in parallel we almost always see a ConcurrentModificationException when DefaultCamelContext passes the routeDefinitions list to RouteDefinitionHelper.validateUniqueIds
> I propose that we fix this by making routeDefinitions (in DefaultCamelContext) a CopyOnWriteArrayList instead of an ArrayList. Apparently this was already done for the lifecycleStrategies list, presumably for the same reason.
> It's also curious that the accessors for this list are marked synchronized. Since the references are final, there's no reason to use volatile instead, so it seems like the synchronized here is pointless.
> I also think we should consider doing the same for restDefinitions, since there is nothing preventing this list from being modified in multiple threads.



--
This message was sent by Atlassian JIRA
(v6.3.4#6332)