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`
(cherry picked from commit 95d292a297)
This commit is contained in:
committed by
Spring Builds
parent
2ec2f2967e
commit
c370cea7b3
@@ -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