Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -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")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -302,6 +309,9 @@ public void run() {

private static final AtomicInteger TASK_SEQUENCE_GENERATOR = new AtomicInteger();

private static final PeriodicTask<Object> FUTURE_NOOP_PLACEHOLDER =
new PeriodicTask<>(null, new Scheduled<>(null), 10, 0, MINUTES);

private static final class PeriodicTask<T> implements Delayed {

private final Task<T> task;
Expand Down