Use correct ClassLoader in MicrometerObservationRegistryTestExecutionListener
In the original implementation of MicrometerObservationRegistryTestExecutionListener I accidentally imported JUnit 5's org.junit.platform.launcher.TestExecutionListener instead Spring's org.springframework.test.context.TestExecutionListener. The code therefore attempts to use the ClassLoader for the JUnit Platform's TestExecutionListener which may fail to see the required types. In addition, if the JUnit Platform's TestExecutionListener is not on the classpath, the attempt to access its ClassLoader will fail. This commit addresses this by properly using the ClassLoader for Spring's TestExecutionListener to detect dependencies of the MicrometerObservationRegistryTestExecutionListener. Closes gh-30726
This commit is contained in:
@@ -22,11 +22,11 @@ import io.micrometer.observation.ObservationRegistry;
|
||||
import io.micrometer.observation.contextpropagation.ObservationThreadLocalAccessor;
|
||||
import org.apache.commons.logging.Log;
|
||||
import org.apache.commons.logging.LogFactory;
|
||||
import org.junit.platform.launcher.TestExecutionListener;
|
||||
|
||||
import org.springframework.context.ApplicationContext;
|
||||
import org.springframework.core.Conventions;
|
||||
import org.springframework.test.context.TestContext;
|
||||
import org.springframework.test.context.TestExecutionListener;
|
||||
import org.springframework.test.context.support.AbstractTestExecutionListener;
|
||||
import org.springframework.util.Assert;
|
||||
import org.springframework.util.ReflectionUtils;
|
||||
|
||||
Reference in New Issue
Block a user