Browse Source
Prior to this commit, dependency checks in the static initialization block for MicrometerObservationRegistryTestExecutionListener resulted in an ExceptionInInitializerError which led to verbose logging in TestContextFailureHandler. This commit improves the logging for missing dependencies in MicrometerObservationRegistryTestExecutionListener by moving the dependency checks to the constructor and by throwing a NoClassDefFoundError instead of an IllegalStateException. This allows TestContextFailureHandler to log a concise DEBUG message denoting that the listener is being skipped due to missing dependencies. This commit also now checks for the presence of io.micrometer.context.ThreadLocalAccessor in addition to io.micrometer.observation.contextpropagation.ObservationThreadLocalAccessor. Furthermore, this commit now explicitly mentions the need for io.micrometer:context-propagation in the error message. The following demonstrate the generated DEBUB message when ObservationThreadLocalAccessor and ThreadLocalAccessor are missing, respectively. Skipping candidate TestExecutionListener [org.springframework.test.context.observation.MicrometerObservationRegistryTestExecutionListener] due to a missing dependency. Specify custom TestExecutionListener classes or make the default TestExecutionListener classes and their required dependencies available. Offending class: io.micrometer.observation.contextpropagation.ObservationThreadLocalAccessor. MicrometerObservationRegistryTestExecutionListener requires io.micrometer:micrometer-observation:1.10.8 or higher and io.micrometer:context-propagation:1.0.3 or higher. Skipping candidate TestExecutionListener [org.springframework.test.context.observation.MicrometerObservationRegistryTestExecutionListener] due to a missing dependency. Specify custom TestExecutionListener classes or make the default TestExecutionListener classes and their required dependencies available. Offending class: io.micrometer.context.ThreadLocalAccessor. MicrometerObservationRegistryTestExecutionListener requires io.micrometer:micrometer-observation:1.10.8 or higher and io.micrometer:context-propagation:1.0.3 or higher. Closes gh-30747pull/30915/head
Sam Brannen
1 year ago
2 changed files with 33 additions and 17 deletions
Loading…
Reference in new issue