Always use reflection to get VM args
This commit is contained in:
parent
ff0cd73381
commit
7b023ca95a
|
@ -44,12 +44,10 @@ public class TracingAgent {
|
||||||
throws Exception {
|
throws Exception {
|
||||||
configureLogger();
|
configureLogger();
|
||||||
|
|
||||||
final boolean usingCustomLogManager = isAppUsingCustomLogManager();
|
final URL bootstrapURL = installBootstrapJar(inst);
|
||||||
|
|
||||||
final URL bootstrapURL = installBootstrapJar(inst, usingCustomLogManager);
|
|
||||||
|
|
||||||
startDatadogAgent(inst, bootstrapURL);
|
startDatadogAgent(inst, bootstrapURL);
|
||||||
if (usingCustomLogManager) {
|
if (isAppUsingCustomLogManager()) {
|
||||||
System.out.println("Custom logger detected. Delaying JMXFetch initialization.");
|
System.out.println("Custom logger detected. Delaying JMXFetch initialization.");
|
||||||
/*
|
/*
|
||||||
* java.util.logging.LogManager maintains a final static LogManager, which is created during class initialization.
|
* java.util.logging.LogManager maintains a final static LogManager, which is created during class initialization.
|
||||||
|
@ -155,8 +153,7 @@ public class TracingAgent {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private static synchronized URL installBootstrapJar(
|
private static synchronized URL installBootstrapJar(final Instrumentation inst)
|
||||||
final Instrumentation inst, final boolean usingCustomLogManager)
|
|
||||||
throws IOException, URISyntaxException {
|
throws IOException, URISyntaxException {
|
||||||
URL bootstrapURL = null;
|
URL bootstrapURL = null;
|
||||||
|
|
||||||
|
@ -180,13 +177,7 @@ public class TracingAgent {
|
||||||
// - On IBM-based JDKs since at least 1.7
|
// - On IBM-based JDKs since at least 1.7
|
||||||
// This prevents custom log managers from working correctly
|
// This prevents custom log managers from working correctly
|
||||||
// Use reflection to bypass the loading of the class
|
// Use reflection to bypass the loading of the class
|
||||||
final List<String> arguments;
|
final List<String> arguments = getVMArgumentsThroughReflection();
|
||||||
if (usingCustomLogManager) {
|
|
||||||
System.out.println("Custom log manager detected: getting vm args through reflection");
|
|
||||||
arguments = getVMArgumentsThroughReflection();
|
|
||||||
} else {
|
|
||||||
arguments = ManagementFactory.getRuntimeMXBean().getInputArguments();
|
|
||||||
}
|
|
||||||
|
|
||||||
String agentArgument = null;
|
String agentArgument = null;
|
||||||
for (final String arg : arguments) {
|
for (final String arg : arguments) {
|
||||||
|
|
Loading…
Reference in New Issue