Skip to content

Only update ObservationThreadLocalAccessor when a test has an active ApplicationContext #36817

@sbrannen

Description

@sbrannen

Overview

While working on the tests for #36782, I noticed that MicrometerObservationRegistryTestExecutionListener eagerly loads an ApplicationContext like MockitoResetTestExecutionListener previously did.

The Javadoc states that it:

updates the ObservationThreadLocalAccessor with the ObservationRegistry obtained from the test's ApplicationContext, if present.

However, the last part is misleading. While it's true that it only does that if the ObservationRegistry is present in the context, it always loads the context to check if the ObservationRegistry is present.

Whereas, it should not do anything if the current test does not have an active ApplicationContext.

Related Issues

Metadata

Metadata

Assignees

Labels

Type

No type
No fields configured for issues without a type.

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions