Skip to content

MeterRegistry throws BeanCreationNotAllowedException on shutdown #38240

@wojciechkedziora

Description

@wojciechkedziora

We use Micrometer with NewRelic in our Spring Boot 3.1.5 applications.

After migration to the newest Spring Boot we noticed that following WARN log always appears during application shutdown:

Failed to apply the value function for the gauge '{{custom_gauge_name}}'. 

The exception behind above log looks like:

`org.springframework.beans.factory.BeanCreationNotAllowedException: Error creating bean with name 'entityManagerFactory': Singleton bean creation not allowed while singletons of this factory are in destruction (Do not request a bean from a BeanFactory in a destroy method implementation!)` 

App is integrated with NewRelic agent - i checked that mentioned exception is triggered when:

at com.newrelic.telemetry.micrometer.NewRelicRegistry.publish(NewRelicRegistry.java:168)	at io.micrometer.core.instrument.push.PushMeterRegistry.publishSafely(PushMeterRegistry.java:67	at io.micrometer.core.instrument.push.PushMeterRegistry.close(PushMeterRegistry.java:135)	at io.micrometer.core.instrument.step.StepMeterRegistry.close(StepMeterRegistry.java:156)	at com.newrelic.telemetry.micrometer.NewRelicRegistry.close(NewRelicRegistry.java:157) 

Please note that similar bug for older Spring Boot 2.2 version was reported under #19557. I've reproduced reported bug: https://github.com/wojciechkedziora/spring-boot-3-19557 (check this comment for more details).

Metadata

Metadata

Assignees

Labels

Type

No type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions