GH-1214: Fix NPE When no Container id or Bean name

Resolves https://github.com/spring-projects/spring-amqp/issues/1214

Micrometer throws an NPE.
This commit is contained in:
Gary Russell
2020-06-22 12:32:26 -04:00
parent ee52539c13
commit 715f39ff3b

View File

@@ -1144,7 +1144,11 @@ public abstract class AbstractMessageListenerContainer extends RabbitAccessor
try {
if (this.micrometerHolder == null && MICROMETER_PRESENT && this.micrometerEnabled
&& this.applicationContext != null) {
this.micrometerHolder = new MicrometerHolder(this.applicationContext, getListenerId(),
String id = getListenerId();
if (id == null) {
id = "no_id_or_beanName";
}
this.micrometerHolder = new MicrometerHolder(this.applicationContext, id,
this.micrometerTags);
}
}