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**
This commit is contained in:
@@ -327,8 +327,8 @@ public abstract class AbstractMessageChannel extends IntegrationObjectSupport
|
|||||||
protected void onInit() throws Exception {
|
protected void onInit() throws Exception {
|
||||||
super.onInit();
|
super.onInit();
|
||||||
if (this.messageConverter == null) {
|
if (this.messageConverter == null) {
|
||||||
if (this.getBeanFactory() != null) {
|
if (getBeanFactory() != null) {
|
||||||
if (this.getBeanFactory().containsBean(
|
if (getBeanFactory().containsBean(
|
||||||
IntegrationContextUtils.INTEGRATION_DATATYPE_CHANNEL_MESSAGE_CONVERTER_BEAN_NAME)) {
|
IntegrationContextUtils.INTEGRATION_DATATYPE_CHANNEL_MESSAGE_CONVERTER_BEAN_NAME)) {
|
||||||
this.messageConverter = this.getBeanFactory().getBean(
|
this.messageConverter = this.getBeanFactory().getBean(
|
||||||
IntegrationContextUtils.INTEGRATION_DATATYPE_CHANNEL_MESSAGE_CONVERTER_BEAN_NAME,
|
IntegrationContextUtils.INTEGRATION_DATATYPE_CHANNEL_MESSAGE_CONVERTER_BEAN_NAME,
|
||||||
@@ -339,6 +339,8 @@ public abstract class AbstractMessageChannel extends IntegrationObjectSupport
|
|||||||
if (this.statsEnabled) {
|
if (this.statsEnabled) {
|
||||||
this.channelMetrics.setFullStatsEnabled(true);
|
this.channelMetrics.setFullStatsEnabled(true);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
this.fullChannelName = null;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -349,8 +351,8 @@ public abstract class AbstractMessageChannel extends IntegrationObjectSupport
|
|||||||
*/
|
*/
|
||||||
public String getFullChannelName() {
|
public String getFullChannelName() {
|
||||||
if (this.fullChannelName == null) {
|
if (this.fullChannelName == null) {
|
||||||
String contextId = this.getApplicationContextId();
|
String contextId = getApplicationContextId();
|
||||||
String componentName = this.getComponentName();
|
String componentName = getComponentName();
|
||||||
componentName = (StringUtils.hasText(contextId) ? contextId + "." : "") +
|
componentName = (StringUtils.hasText(contextId) ? contextId + "." : "") +
|
||||||
(StringUtils.hasText(componentName) ? componentName : "unknown.channel.name");
|
(StringUtils.hasText(componentName) ? componentName : "unknown.channel.name");
|
||||||
this.fullChannelName = componentName;
|
this.fullChannelName = componentName;
|
||||||
|
|||||||
Reference in New Issue
Block a user