From 19696254dddf169fa62d502a53fa0351bad3d080 Mon Sep 17 00:00:00 2001 From: Matt Pavlovich Date: Tue, 7 Nov 2023 08:12:46 -0600 Subject: [PATCH] [AMQ-9376] Fix ConcurrentModificationException during a destroy() --- .../java/org/apache/activemq/osgi/ActiveMQServiceFactory.java | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/activemq-osgi/src/main/java/org/apache/activemq/osgi/ActiveMQServiceFactory.java b/activemq-osgi/src/main/java/org/apache/activemq/osgi/ActiveMQServiceFactory.java index e507dd4562..254007e085 100644 --- a/activemq-osgi/src/main/java/org/apache/activemq/osgi/ActiveMQServiceFactory.java +++ b/activemq-osgi/src/main/java/org/apache/activemq/osgi/ActiveMQServiceFactory.java @@ -22,6 +22,7 @@ import java.util.Enumeration; import java.util.HashMap; import java.util.Map; import java.util.Properties; +import java.util.Set; import org.apache.activemq.broker.BrokerService; import org.apache.activemq.spring.SpringBrokerContext; @@ -182,7 +183,8 @@ public class ActiveMQServiceFactory implements ManagedServiceFactory { } synchronized public void destroy() { - for (String broker : brokers.keySet()) { + Set tmpBrokersSet = brokers.keySet(); + for (String broker : tmpBrokersSet) { deleted(broker); } }