File tree Expand file tree Collapse file tree
dd-java-agent/instrumentation/maven/maven-3.2.1/src/test/groovy Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -2,6 +2,7 @@ import datadog.trace.api.config.CiVisibilityConfig
22import datadog.trace.civisibility.CiVisibilityInstrumentationTest
33import org.apache.maven.cli.MavenCli
44import org.codehaus.plexus.util.FileUtils
5+ import org.slf4j.MDC
56import spock.lang.TempDir
67
78import java.nio.file.Path
@@ -18,6 +19,14 @@ class MavenInstrumentationTest extends CiVisibilityInstrumentationTest {
1819
1920 @Override
2021 def setup () {
22+ // Workaround for maven-surefire 3.5.5 bug (https://github.com/apache/maven-surefire/pull/3241):
23+ // ThreadedStreamConsumer$Pumper.run() calls MDC.setContextMap(MDC.getCopyOfContextMap()),
24+ // but LogbackMDCAdapter.getCopyOfContextMap() returns null when MDC is uninitialized,
25+ // and LogbackMDCAdapter.setContextMap(null) throws NPE via HashMap.putAll(null).
26+ // Pre-initializing MDC ensures getCopyOfContextMap() returns an empty map instead of null.
27+ MDC . put(" _init" , " true" )
28+ MDC . remove(" _init" )
29+
2130 System . setProperty(" maven.multiModuleProjectDirectory" , projectFolder. toAbsolutePath(). toString())
2231 givenMavenProjectFiles((String ) specificationContext. currentIteration. dataVariables. testcaseName)
2332 givenMavenDependenciesAreLoaded()
You can’t perform that action at this time.
0 commit comments