From 96a74a549bb6eb0abc5f8ec92aa9308cf12c48a4 Mon Sep 17 00:00:00 2001 From: Stuart McCulloch Date: Fri, 15 May 2026 15:03:02 +0100 Subject: [PATCH] Defer starting DebuggerAgent until shared comms is ready. In certain environments we need to hold back shared-communication over OkHttp because it may trigger early loading of things like JUL which can break apps that expect to set a custom log manager. At the moment we do this via SharedCommunicationObjects::whenReady - if comms is allowed the call goes ahead immediately, otherwise it is temporarily delayed until we know it is safe to proceed. This mechanism will hopefully be replaced eventually by a run-level style approach, but until then any services that are on by default and might use OkHttp should use this method to co-operate with the overall Agent startup. The DebuggerAgent has been gradually enabling more and more features by default, including recently source file tracking and symbol uploads. Since these may call out using OkHttp they should use SharedCommunicationObjects::whenReady. Given the current codebase structure the easiest way to apply this was on the main DebuggerAgent::run method. --- .../main/java/com/datadog/debugger/agent/DebuggerAgent.java | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/dd-java-agent/agent-debugger/src/main/java/com/datadog/debugger/agent/DebuggerAgent.java b/dd-java-agent/agent-debugger/src/main/java/com/datadog/debugger/agent/DebuggerAgent.java index 843d2504b15..577911ad602 100644 --- a/dd-java-agent/agent-debugger/src/main/java/com/datadog/debugger/agent/DebuggerAgent.java +++ b/dd-java-agent/agent-debugger/src/main/java/com/datadog/debugger/agent/DebuggerAgent.java @@ -75,7 +75,11 @@ public class DebuggerAgent { static final AtomicBoolean symDBEnabled = new AtomicBoolean(); private static ClassesToRetransformFinder classesToRetransformFinder; - public static synchronized void run( + public static void run(Config config, Instrumentation inst, SharedCommunicationObjects sco) { + sco.whenReady(() -> doRun(config, inst, sco)); + } + + private static synchronized void doRun( Config config, Instrumentation inst, SharedCommunicationObjects sco) { instrumentation = inst; sharedCommunicationObjects = sco;