From 52faf0446900cf169d5574fa470bfe4e71007011 Mon Sep 17 00:00:00 2001 From: Gary Russell Date: Tue, 3 Jan 2012 11:15:20 -0500 Subject: [PATCH] INT-2347 Update Channel Mappings Atomically Ensure consistent state if channel map is replaced dynamically. Backport to 2.0.x. --- .../integration/router/AbstractMessageRouter.java | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/spring-integration-core/src/main/java/org/springframework/integration/router/AbstractMessageRouter.java b/spring-integration-core/src/main/java/org/springframework/integration/router/AbstractMessageRouter.java index 731ac17cbb..0507afe374 100644 --- a/spring-integration-core/src/main/java/org/springframework/integration/router/AbstractMessageRouter.java +++ b/spring-integration-core/src/main/java/org/springframework/integration/router/AbstractMessageRouter.java @@ -47,6 +47,7 @@ import org.springframework.util.StringUtils; * * @author Mark Fisher * @author Oleg Zhurakousky + * @author Gary Russell */ @ManagedResource public abstract class AbstractMessageRouter extends AbstractMessageHandler { @@ -101,8 +102,14 @@ public abstract class AbstractMessageRouter extends AbstractMessageHandler { * @param channelIdentifierMap */ public void setChannelIdentifierMap(Map channelIdentifierMap) { - this.channelIdentifierMap.clear(); - this.channelIdentifierMap.putAll(channelIdentifierMap); + Map oldChannelIdentifierMap = this.channelIdentifierMap; + Map newChannelIdentifierMap = new ConcurrentHashMap(); + newChannelIdentifierMap.putAll(channelIdentifierMap); + this.channelIdentifierMap = newChannelIdentifierMap; + if (logger.isDebugEnabled()) { + logger.debug("Channel mappings:" + oldChannelIdentifierMap + + " replaced with:" + newChannelIdentifierMap); + } } @ManagedOperation