Merge pull request #1081 from DataDog/mar-kolya/minor-cleanup
minor cleanup
This commit is contained in:
commit
94d3b829d2
|
@ -108,7 +108,7 @@ public class JMXFetch {
|
||||||
} catch (final InterruptedException e) {
|
} catch (final InterruptedException e) {
|
||||||
// It looks like JMXFetch itself eats up InterruptedException, so we will do
|
// It looks like JMXFetch itself eats up InterruptedException, so we will do
|
||||||
// same here for consistency
|
// same here for consistency
|
||||||
log.error("JMXFetch was interupted, ignoring", e);
|
log.error("JMXFetch was interrupted, ignoring", e);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -270,13 +270,7 @@ public class AgentInstaller {
|
||||||
final String typeName,
|
final String typeName,
|
||||||
final ClassLoader classLoader,
|
final ClassLoader classLoader,
|
||||||
final JavaModule javaModule,
|
final JavaModule javaModule,
|
||||||
final boolean b) {
|
final boolean b) {}
|
||||||
for (final Map.Entry<String, Runnable> entry : classLoadCallbacks.entrySet()) {
|
|
||||||
if (entry.getKey().equals(typeName)) {
|
|
||||||
entry.getValue().run();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onTransformation(
|
public void onTransformation(
|
||||||
|
@ -303,10 +297,16 @@ public class AgentInstaller {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onComplete(
|
public void onComplete(
|
||||||
final String s,
|
final String typeName,
|
||||||
final ClassLoader classLoader,
|
final ClassLoader classLoader,
|
||||||
final JavaModule javaModule,
|
final JavaModule javaModule,
|
||||||
final boolean b) {}
|
final boolean b) {
|
||||||
|
for (final Map.Entry<String, Runnable> entry : classLoadCallbacks.entrySet()) {
|
||||||
|
if (entry.getKey().equals(typeName)) {
|
||||||
|
entry.getValue().run();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private AgentInstaller() {}
|
private AgentInstaller() {}
|
||||||
|
|
|
@ -52,11 +52,15 @@ public class TracingAgent {
|
||||||
/*
|
/*
|
||||||
* 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.
|
||||||
*
|
*
|
||||||
* JMXFetch uses jre bootstrap classes which touch this class. This means applications which require a custom log manager may not have a chance to set the global log manager if jmxfetch runs first. JMXFetch will incorrectly set the global log manager in cases where the app sets the log manager system property or when the log manager class is not on the system classpath.
|
* JMXFetch uses jre bootstrap classes which touch this class. This means applications which require a custom log
|
||||||
|
* manager may not have a chance to set the global log manager if jmxfetch runs first. JMXFetch will incorrectly
|
||||||
|
* set the global log manager in cases where the app sets the log manager system property or when the log manager
|
||||||
|
* class is not on the system classpath.
|
||||||
*
|
*
|
||||||
* Our solution is to delay the initilization of jmxfetch when we detect a custom log manager being used.
|
* Our solution is to delay the initialization of jmxfetch when we detect a custom log manager being used.
|
||||||
*
|
*
|
||||||
* Once we see the LogManager class loading, it's safe to start jmxfetch because the application is already setting the global log manager and jmxfetch won't be able to touch it due to classloader locking.
|
* Once we see the LogManager class loading, it's safe to start jmxfetch because the application is already setting
|
||||||
|
* the global log manager and jmxfetch won't be able to touch it due to classloader locking.
|
||||||
*/
|
*/
|
||||||
final Class<?> agentInstallerClass =
|
final Class<?> agentInstallerClass =
|
||||||
AGENT_CLASSLOADER.loadClass("datadog.trace.agent.tooling.AgentInstaller");
|
AGENT_CLASSLOADER.loadClass("datadog.trace.agent.tooling.AgentInstaller");
|
||||||
|
@ -83,7 +87,6 @@ public class TracingAgent {
|
||||||
try {
|
try {
|
||||||
startJmxFetch(inst, bootstrapURL);
|
startJmxFetch(inst, bootstrapURL);
|
||||||
} catch (final Exception e) {
|
} catch (final Exception e) {
|
||||||
e.printStackTrace();
|
|
||||||
throw new RuntimeException(e);
|
throw new RuntimeException(e);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -265,8 +268,7 @@ public class TracingAgent {
|
||||||
private static ClassLoader createDatadogClassLoader(
|
private static ClassLoader createDatadogClassLoader(
|
||||||
final String innerJarFilename, final URL bootstrapURL) throws Exception {
|
final String innerJarFilename, final URL bootstrapURL) throws Exception {
|
||||||
final ClassLoader agentParent;
|
final ClassLoader agentParent;
|
||||||
final String javaVersion = System.getProperty("java.version");
|
if (isJavaBefore9()) {
|
||||||
if (javaVersion.startsWith("1.7") || javaVersion.startsWith("1.8")) {
|
|
||||||
agentParent = null; // bootstrap
|
agentParent = null; // bootstrap
|
||||||
} else {
|
} else {
|
||||||
// platform classloader is parent of system in java 9+
|
// platform classloader is parent of system in java 9+
|
||||||
|
@ -372,6 +374,10 @@ public class TracingAgent {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private static boolean isJavaBefore9() {
|
||||||
|
return System.getProperty("java.version").startsWith("1.");
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Main entry point.
|
* Main entry point.
|
||||||
*
|
*
|
||||||
|
|
Loading…
Reference in New Issue