Skip to content

Commit c4beb14

Browse files
committed
Only apply workaround to the global task scheduler used during premain
1 parent a73fd0b commit c4beb14

File tree

1 file changed

+6
-4
lines changed

1 file changed

+6
-4
lines changed

internal-api/src/main/java/datadog/trace/util/AgentTaskScheduler.java

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -226,10 +226,12 @@ private void prepareWorkQueue() {
226226
} catch (final InterruptedException e) {
227227
// ignore, we only want to preload queue internals
228228
}
229-
// preload a future no-op task to ensure workQueue.take() will use await with timeout during
230-
// premain - otherwise on Java 25 it will load ForkJoinPool which in turn loads ForkJoinTask,
231-
// which then means we lose the chance to field-inject context into ForkJoinTask instances
232-
workQueue.offer(FUTURE_NOOP_PLACEHOLDER);
229+
if (this == INSTANCE) {
230+
// preload a future no-op task to ensure workQueue.take() will use await with timeout during
231+
// premain - otherwise on Java 25 it will load ForkJoinPool which in turn loads ForkJoinTask,
232+
// which then means we lose the chance to field-inject context into ForkJoinTask instances
233+
workQueue.offer(FUTURE_NOOP_PLACEHOLDER);
234+
}
233235
}
234236

235237
// for testing

0 commit comments

Comments
 (0)