diff --git a/dd-smoke-tests/field-injection/src/test/groovy/datadog/smoketest/FieldInjectionSmokeTest.groovy b/dd-smoke-tests/field-injection/src/test/groovy/datadog/smoketest/FieldInjectionSmokeTest.groovy index 1104e13d721..e321595422c 100644 --- a/dd-smoke-tests/field-injection/src/test/groovy/datadog/smoketest/FieldInjectionSmokeTest.groovy +++ b/dd-smoke-tests/field-injection/src/test/groovy/datadog/smoketest/FieldInjectionSmokeTest.groovy @@ -61,7 +61,6 @@ class FieldInjectionSmokeTest extends Specification { command.add("-XX:ErrorFile=/tmp/hs_err_pid%p.log") // turn off these features as their debug output can break up our expected logging lines on IBM JVMs // causing random test failures (we are not testing these features here so they don't need to be on) - command.add("-Ddd.crashtracking.enabled=false") command.add("-Ddd.instrumentation.telemetry.enabled=false") command.add("-Ddd.remote_config.enabled=false") command.add("-Ddd.writer.type=TraceStructureWriter") diff --git a/internal-api/src/main/java/datadog/trace/util/AgentTaskScheduler.java b/internal-api/src/main/java/datadog/trace/util/AgentTaskScheduler.java index af338b01444..3620dbfe515 100644 --- a/internal-api/src/main/java/datadog/trace/util/AgentTaskScheduler.java +++ b/internal-api/src/main/java/datadog/trace/util/AgentTaskScheduler.java @@ -4,6 +4,7 @@ import static datadog.trace.util.AgentThreadFactory.AgentThread.TASK_SCHEDULER; import static datadog.trace.util.AgentThreadFactory.newAgentThread; import static java.util.concurrent.TimeUnit.MILLISECONDS; +import static java.util.concurrent.TimeUnit.MINUTES; import static java.util.concurrent.TimeUnit.NANOSECONDS; import static java.util.concurrent.TimeUnit.SECONDS; @@ -225,6 +226,12 @@ private void prepareWorkQueue() { } catch (final InterruptedException e) { // ignore, we only want to preload queue internals } + if (this == INSTANCE) { + // preload a future no-op task to ensure workQueue.take() will use await with timeout during + // premain - otherwise on Java 25 it will load ForkJoinPool which in turn loads ForkJoinTask, + // which then means we lose the chance to field-inject context into ForkJoinTask instances + workQueue.offer(FUTURE_NOOP_PLACEHOLDER); + } } // for testing @@ -302,6 +309,9 @@ public void run() { private static final AtomicInteger TASK_SEQUENCE_GENERATOR = new AtomicInteger(); + private static final PeriodicTask FUTURE_NOOP_PLACEHOLDER = + new PeriodicTask<>(null, new Scheduled<>(null), 10, 0, MINUTES); + private static final class PeriodicTask implements Delayed { private final Task task;