diff --git a/activemq-broker/src/main/java/org/apache/activemq/broker/region/AbstractRegion.java b/activemq-broker/src/main/java/org/apache/activemq/broker/region/AbstractRegion.java index 7f7b7e4c99..2d1171d71c 100755 --- a/activemq-broker/src/main/java/org/apache/activemq/broker/region/AbstractRegion.java +++ b/activemq-broker/src/main/java/org/apache/activemq/broker/region/AbstractRegion.java @@ -583,16 +583,23 @@ public abstract class AbstractRegion implements Region { } public void reapplyInterceptor() { - DestinationInterceptor destinationInterceptor = broker.getDestinationInterceptor(); - Map map = getDestinationMap(); - for (ActiveMQDestination key : map.keySet()) { - Destination destination = map.get(key); - if (destination instanceof CompositeDestinationFilter) { - destination = ((CompositeDestinationFilter)destination).next; + destinationsLock.writeLock().lock(); + try { + DestinationInterceptor destinationInterceptor = broker.getDestinationInterceptor(); + Map map = getDestinationMap(); + for (ActiveMQDestination key : map.keySet()) { + Destination destination = map.get(key); + if (destination instanceof CompositeDestinationFilter) { + destination = ((CompositeDestinationFilter) destination).next; + } + if (destinationInterceptor != null) { + destination = destinationInterceptor.intercept(destination); + } + getDestinationMap().put(key, destination); + destinations.put(key, destination); } - destination = destinationInterceptor.intercept(destination); - getDestinationMap().put(key, destination); - destinations.put(key, destination); + } finally { + destinationsLock.writeLock().unlock(); } } } diff --git a/activemq-runtime-config/src/main/java/org/apache/activemq/plugin/RuntimeConfigurationBroker.java b/activemq-runtime-config/src/main/java/org/apache/activemq/plugin/RuntimeConfigurationBroker.java index 73c172d923..b11b529502 100644 --- a/activemq-runtime-config/src/main/java/org/apache/activemq/plugin/RuntimeConfigurationBroker.java +++ b/activemq-runtime-config/src/main/java/org/apache/activemq/plugin/RuntimeConfigurationBroker.java @@ -552,6 +552,7 @@ public class RuntimeConfigurationBroker extends BrokerFilter { public void run() { boolean updatedExistingInterceptor = false; + RegionBroker regionBroker = (RegionBroker) getBrokerService().getRegionBroker(); for (DestinationInterceptor destinationInterceptor : getBrokerService().getDestinationInterceptors()) { if (destinationInterceptor instanceof VirtualDestinationInterceptor) { @@ -577,11 +578,11 @@ public class RuntimeConfigurationBroker extends BrokerFilter { DestinationInterceptor[] destinationInterceptors = interceptorsList.toArray(new DestinationInterceptor[]{}); getBrokerService().setDestinationInterceptors(destinationInterceptors); - RegionBroker regionBroker = (RegionBroker) getBrokerService().getRegionBroker(); + ((CompositeDestinationInterceptor) regionBroker.getDestinationInterceptor()).setInterceptors(destinationInterceptors); info("applied new: " + interceptorsList); - regionBroker.reapplyInterceptor(); } + regionBroker.reapplyInterceptor(); } }); } else if (o instanceof DtoPolicyEntry) {