From 2b17fd805098e0c42821dacd5695db067ce594f6 Mon Sep 17 00:00:00 2001 From: Timothy Bish Date: Wed, 11 Feb 2015 17:22:26 -0500 Subject: [PATCH] https://issues.apache.org/jira/browse/AMQ-5580 Use a CopyOnWriteArrayList to ensure that traversals of the adapters list do not generate ConcurrentModificationException if a new adapter is added during that time. --- .../store/kahadb/MultiKahaDBPersistenceAdapter.java | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/activemq-kahadb-store/src/main/java/org/apache/activemq/store/kahadb/MultiKahaDBPersistenceAdapter.java b/activemq-kahadb-store/src/main/java/org/apache/activemq/store/kahadb/MultiKahaDBPersistenceAdapter.java index f22e544f61..286931eb76 100644 --- a/activemq-kahadb-store/src/main/java/org/apache/activemq/store/kahadb/MultiKahaDBPersistenceAdapter.java +++ b/activemq-kahadb-store/src/main/java/org/apache/activemq/store/kahadb/MultiKahaDBPersistenceAdapter.java @@ -20,7 +20,13 @@ import java.io.File; import java.io.FileFilter; import java.io.IOException; import java.nio.charset.Charset; -import java.util.*; +import java.util.Collections; +import java.util.HashMap; +import java.util.HashSet; +import java.util.List; +import java.util.Map; +import java.util.Set; +import java.util.concurrent.CopyOnWriteArrayList; import javax.transaction.xa.Xid; @@ -78,7 +84,7 @@ public class MultiKahaDBPersistenceAdapter extends LockableServiceSupport implem final DelegateDestinationMap destinationMap = new DelegateDestinationMap(); BrokerService brokerService; - List adapters = new LinkedList(); + List adapters = new CopyOnWriteArrayList(); private File directory = new File(IOHelper.getDefaultDataDirectory() + File.separator + "mKahaDB"); MultiKahaDBTransactionStore transactionStore = new MultiKahaDBTransactionStore(this);