From 7bd539b9b02dbcd93fd54cd6e07c7f061fa8cf72 Mon Sep 17 00:00:00 2001 From: Artem Bilan Date: Fri, 4 Aug 2017 13:19:46 -0400 Subject: [PATCH] Reset `AbstractMessageChannel.fullChannelName` Fixes spring-cloud/spring-cloud-stream#983 When the `AbstractMessageChannel.getFullChannelName()` is called before the full bean initialization, we don't have the proper name any more lately - that is only `unknown.channel.name` * Reset `fullChannelName` property to `null` in the end of `onInit()`, so the next `getFullChannelName()` will build the proper component name **Cherry-pick to 4.3.x** (cherry picked from commit 5a25993) --- .../integration/channel/AbstractMessageChannel.java | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/spring-integration-core/src/main/java/org/springframework/integration/channel/AbstractMessageChannel.java b/spring-integration-core/src/main/java/org/springframework/integration/channel/AbstractMessageChannel.java index 63415250a6..98931c7a5b 100644 --- a/spring-integration-core/src/main/java/org/springframework/integration/channel/AbstractMessageChannel.java +++ b/spring-integration-core/src/main/java/org/springframework/integration/channel/AbstractMessageChannel.java @@ -327,8 +327,8 @@ public abstract class AbstractMessageChannel extends IntegrationObjectSupport protected void onInit() throws Exception { super.onInit(); if (this.messageConverter == null) { - if (this.getBeanFactory() != null) { - if (this.getBeanFactory().containsBean( + if (getBeanFactory() != null) { + if (getBeanFactory().containsBean( IntegrationContextUtils.INTEGRATION_DATATYPE_CHANNEL_MESSAGE_CONVERTER_BEAN_NAME)) { this.messageConverter = this.getBeanFactory().getBean( IntegrationContextUtils.INTEGRATION_DATATYPE_CHANNEL_MESSAGE_CONVERTER_BEAN_NAME, @@ -339,6 +339,8 @@ public abstract class AbstractMessageChannel extends IntegrationObjectSupport if (this.statsEnabled) { this.channelMetrics.setFullStatsEnabled(true); } + + this.fullChannelName = null; } /** @@ -349,8 +351,8 @@ public abstract class AbstractMessageChannel extends IntegrationObjectSupport */ public String getFullChannelName() { if (this.fullChannelName == null) { - String contextId = this.getApplicationContextId(); - String componentName = this.getComponentName(); + String contextId = getApplicationContextId(); + String componentName = getComponentName(); componentName = (StringUtils.hasText(contextId) ? contextId + "." : "") + (StringUtils.hasText(componentName) ? componentName : "unknown.channel.name"); this.fullChannelName = componentName;