Skip to content

Commit 42ea301

Browse files
committed
Make sure we load core JMX using the deferred callback's inherited thread-context-classloader (TCCL)
This handles a situation where the app thread triggering JMX has a special thread-context-classloader set that can see the custom JMX builder class. The callback thread inherits this TCCL so we just need to make sure to load core JMX using this before starting JMXFetch (which needs a different TCCL set.)
1 parent 1e07b3d commit 42ea301

File tree

1 file changed

+4
-0
lines changed
  • dd-java-agent/agent-bootstrap/src/main/java/datadog/trace/bootstrap

1 file changed

+4
-0
lines changed

dd-java-agent/agent-bootstrap/src/main/java/datadog/trace/bootstrap/Agent.java

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
package datadog.trace.bootstrap;
22

33
import java.lang.instrument.Instrumentation;
4+
import java.lang.management.ManagementFactory;
45
import java.lang.reflect.Constructor;
56
import java.lang.reflect.InvocationTargetException;
67
import java.lang.reflect.Method;
@@ -281,6 +282,9 @@ private static synchronized void installDatadogTracer() {
281282
}
282283

283284
private static synchronized void startJmx(final URL bootstrapURL) {
285+
// load core JMX using the inherited thread-context-classloader
286+
ManagementFactory.getPlatformMBeanServer();
287+
284288
startJmxFetch(bootstrapURL);
285289

286290
if (AGENT_CLASSLOADER == null) {

0 commit comments

Comments
 (0)