Skip to content

Commit

Permalink
Use correct ClassLoader in MicrometerObservationRegistryTestExecution…
Browse files Browse the repository at this point in the history
…Listener

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 spring-projectsgh-30726
  • Loading branch information
sbrannen authored and mdeinum committed Jun 29, 2023
1 parent 3252726 commit 9cd8a65
Showing 1 changed file with 1 addition and 1 deletion.
Expand Up @@ -22,11 +22,11 @@
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;
Expand Down

0 comments on commit 9cd8a65

Please sign in to comment.