Skip to content

Commit

Permalink
Fix NPE for RabbitAccessor.observationRegistry
Browse files Browse the repository at this point in the history
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`**
  • Loading branch information
artembilan committed Feb 14, 2024
1 parent 61e7a5e commit 95d292a
Showing 1 changed file with 3 additions and 2 deletions.
Original file line number Diff line number Diff line change
@@ -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.
Expand Down Expand Up @@ -33,6 +33,7 @@
* @author Mark Fisher
* @author Dave Syer
* @author Gary Russell
* @author Artem Bilan
*/
public abstract class RabbitAccessor implements InitializingBean {

Expand Down Expand Up @@ -122,7 +123,7 @@ protected void obtainObservationRegistry(@Nullable ApplicationContext appContext
if (appContext != null) {
ObjectProvider<ObservationRegistry> registry =
appContext.getBeanProvider(ObservationRegistry.class);
this.observationRegistry = registry.getIfUnique();
this.observationRegistry = registry.getIfUnique(() -> this.observationRegistry);
}
}

Expand Down

0 comments on commit 95d292a

Please sign in to comment.