Fix NPE for RabbitAccessor.observationRegistry
When observation is enabled on component, but no `ObservationRegistry` bean in the application context, we must fall back to the default one `ObservationRegistry.NOOP` **Auto-cherry-pick to `3.0.x`**
This commit is contained in:
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2002-2022 the original author or authors.
|
||||
* Copyright 2002-2024 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -33,6 +33,7 @@ import io.micrometer.observation.ObservationRegistry;
|
||||
* @author Mark Fisher
|
||||
* @author Dave Syer
|
||||
* @author Gary Russell
|
||||
* @author Artem Bilan
|
||||
*/
|
||||
public abstract class RabbitAccessor implements InitializingBean {
|
||||
|
||||
@@ -122,7 +123,7 @@ public abstract class RabbitAccessor implements InitializingBean {
|
||||
if (appContext != null) {
|
||||
ObjectProvider<ObservationRegistry> registry =
|
||||
appContext.getBeanProvider(ObservationRegistry.class);
|
||||
this.observationRegistry = registry.getIfUnique();
|
||||
this.observationRegistry = registry.getIfUnique(() -> this.observationRegistry);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user