From 1c443c53d70a1d8dd420dc565ac904963a243e02 Mon Sep 17 00:00:00 2001 From: Daniel Mohedano Date: Mon, 23 Feb 2026 13:15:09 +0100 Subject: [PATCH 1/2] fix: maven-failsafe-plugin 3.5.5 workaround --- .../src/test/groovy/MavenInstrumentationTest.groovy | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/dd-java-agent/instrumentation/maven/maven-3.2.1/src/test/groovy/MavenInstrumentationTest.groovy b/dd-java-agent/instrumentation/maven/maven-3.2.1/src/test/groovy/MavenInstrumentationTest.groovy index a2c1e0c4db0..ad5f991cb41 100644 --- a/dd-java-agent/instrumentation/maven/maven-3.2.1/src/test/groovy/MavenInstrumentationTest.groovy +++ b/dd-java-agent/instrumentation/maven/maven-3.2.1/src/test/groovy/MavenInstrumentationTest.groovy @@ -2,6 +2,7 @@ import datadog.trace.api.config.CiVisibilityConfig import datadog.trace.civisibility.CiVisibilityInstrumentationTest import org.apache.maven.cli.MavenCli import org.codehaus.plexus.util.FileUtils +import org.slf4j.MDC import spock.lang.TempDir import java.nio.file.Path @@ -18,6 +19,14 @@ class MavenInstrumentationTest extends CiVisibilityInstrumentationTest { @Override def setup() { + // Workaround for maven-surefire 3.5.5 bug (https://github.com/apache/maven-surefire/pull/3241): + // ThreadedStreamConsumer$Pumper.run() calls MDC.setContextMap(MDC.getCopyOfContextMap()), + // but LogbackMDCAdapter.getCopyOfContextMap() returns null when MDC is uninitialized, + // and LogbackMDCAdapter.setContextMap(null) throws NPE via HashMap.putAll(null). + // Pre-initializing MDC ensures getCopyOfContextMap() returns an empty map instead of null. + MDC.put("_init", "true") + MDC.remove("_init") + System.setProperty("maven.multiModuleProjectDirectory", projectFolder.toAbsolutePath().toString()) givenMavenProjectFiles((String) specificationContext.currentIteration.dataVariables.testcaseName) givenMavenDependenciesAreLoaded() From 6fe1b50a7c886e1db18c6ac168be83bd530bd7f8 Mon Sep 17 00:00:00 2001 From: Daniel Mohedano Date: Mon, 23 Feb 2026 15:18:14 +0100 Subject: [PATCH 2/2] chore: revert skips --- .../maven/maven-3.2.1/build.gradle | 4 ---- .../groovy/MavenInstrumentationTest.groovy | 23 ++++++++----------- 2 files changed, 9 insertions(+), 18 deletions(-) diff --git a/dd-java-agent/instrumentation/maven/maven-3.2.1/build.gradle b/dd-java-agent/instrumentation/maven/maven-3.2.1/build.gradle index a8bde5b71f8..6afad36c487 100644 --- a/dd-java-agent/instrumentation/maven/maven-3.2.1/build.gradle +++ b/dd-java-agent/instrumentation/maven/maven-3.2.1/build.gradle @@ -11,10 +11,6 @@ muzzle { addTestSuiteForDir('latestDepTest', 'test') -tasks.named("latestDepTest", Test) { - systemProperty 'test.isLatestDepTest', 'true' -} - dependencies { compileOnly 'org.apache.maven:maven-embedder:3.2.1' diff --git a/dd-java-agent/instrumentation/maven/maven-3.2.1/src/test/groovy/MavenInstrumentationTest.groovy b/dd-java-agent/instrumentation/maven/maven-3.2.1/src/test/groovy/MavenInstrumentationTest.groovy index b74037f5ad7..ad5f991cb41 100644 --- a/dd-java-agent/instrumentation/maven/maven-3.2.1/src/test/groovy/MavenInstrumentationTest.groovy +++ b/dd-java-agent/instrumentation/maven/maven-3.2.1/src/test/groovy/MavenInstrumentationTest.groovy @@ -9,7 +9,6 @@ import java.nio.file.Path import java.nio.file.Paths import static org.junit.jupiter.api.Assertions.assertEquals -import static org.junit.jupiter.api.Assumptions.abort class MavenInstrumentationTest extends CiVisibilityInstrumentationTest { @@ -41,10 +40,6 @@ class MavenInstrumentationTest extends CiVisibilityInstrumentationTest { } def "test #testcaseName"() { - if (skipLatest && Boolean.getBoolean("test.isLatestDepTest")) { - abort("Skipping latest dep test") - } - String workingDirectory = projectFolder.toString() def exitCode = new MavenCli().doMain(args.toArray(new String[0]), workingDirectory, null, null) @@ -53,15 +48,15 @@ class MavenInstrumentationTest extends CiVisibilityInstrumentationTest { assertSpansData(testcaseName) where: - testcaseName | args | expectedExitCode | skipLatest - "test_maven_build_with_no_tests_generates_spans" | ["-B", "verify"] | 0 | false - "test_maven_build_with_incorrect_command_generates_spans" | ["-B", "unknownPhase"] | 1 | false - "test_maven_build_with_tests_generates_spans" | ["-B", "clean", "test"] | 0 | false - "test_maven_build_with_failed_tests_generates_spans" | ["-B", "clean", "test"] | 1 | false - "test_maven_build_with_tests_in_multiple_modules_generates_spans" | ["-B", "clean", "test"] | 1 | false - "test_maven_build_with_tests_in_multiple_modules_run_in_parallel_generates_spans" | ["-B", "-T4", "clean", "test"] | 0 | false - "test_maven_build_with_unit_and_integration_tests_generates_spans" | ["-B", "verify"] | 0 | true // temporary workaround to avoid failures with maven-failsafe-plugin 3.5.5 - "test_maven_build_with_no_fork_generates_spans" | ["-B", "clean", "test"] | 0 | false + testcaseName | args | expectedExitCode + "test_maven_build_with_no_tests_generates_spans" | ["-B", "verify"] | 0 + "test_maven_build_with_incorrect_command_generates_spans" | ["-B", "unknownPhase"] | 1 + "test_maven_build_with_tests_generates_spans" | ["-B", "clean", "test"] | 0 + "test_maven_build_with_failed_tests_generates_spans" | ["-B", "clean", "test"] | 1 + "test_maven_build_with_tests_in_multiple_modules_generates_spans" | ["-B", "clean", "test"] | 1 + "test_maven_build_with_tests_in_multiple_modules_run_in_parallel_generates_spans" | ["-B", "-T4", "clean", "test"] | 0 + "test_maven_build_with_unit_and_integration_tests_generates_spans" | ["-B", "verify"] | 0 + "test_maven_build_with_no_fork_generates_spans" | ["-B", "clean", "test"] | 0 } private void givenMavenProjectFiles(String projectFilesSources) {