Browse Source

Merge pull request #1081 from DataDog/mar-kolya/minor-cleanup

minor cleanup
Tyler Benson 5 years ago
parent
commit
94d3b829d2

+ 1 - 1
dd-java-agent/agent-jmxfetch/src/main/java/datadog/trace/agent/jmxfetch/JMXFetch.java

@@ -108,7 +108,7 @@ public class JMXFetch {
                   } catch (final InterruptedException e) {
                     // It looks like JMXFetch itself eats up InterruptedException, so we will do
                     // same here for consistency
-                    log.error("JMXFetch was interupted, ignoring", e);
+                    log.error("JMXFetch was interrupted, ignoring", e);
                   }
                 }
               }

+ 9 - 9
dd-java-agent/agent-tooling/src/main/java/datadog/trace/agent/tooling/AgentInstaller.java

@@ -270,13 +270,7 @@ public class AgentInstaller {
         final String typeName,
         final ClassLoader classLoader,
         final JavaModule javaModule,
-        final boolean b) {
-      for (final Map.Entry<String, Runnable> entry : classLoadCallbacks.entrySet()) {
-        if (entry.getKey().equals(typeName)) {
-          entry.getValue().run();
-        }
-      }
-    }
+        final boolean b) {}
 
     @Override
     public void onTransformation(
@@ -303,10 +297,16 @@ public class AgentInstaller {
 
     @Override
     public void onComplete(
-        final String s,
+        final String typeName,
         final ClassLoader classLoader,
         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() {}

+ 12 - 6
dd-java-agent/src/main/java/datadog/trace/agent/TracingAgent.java

@@ -52,11 +52,15 @@ public class TracingAgent {
       /*
        * 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 =
           AGENT_CLASSLOADER.loadClass("datadog.trace.agent.tooling.AgentInstaller");
@@ -83,7 +87,6 @@ public class TracingAgent {
       try {
         startJmxFetch(inst, bootstrapURL);
       } catch (final Exception e) {
-        e.printStackTrace();
         throw new RuntimeException(e);
       }
     }
@@ -265,8 +268,7 @@ public class TracingAgent {
   private static ClassLoader createDatadogClassLoader(
       final String innerJarFilename, final URL bootstrapURL) throws Exception {
     final ClassLoader agentParent;
-    final String javaVersion = System.getProperty("java.version");
-    if (javaVersion.startsWith("1.7") || javaVersion.startsWith("1.8")) {
+    if (isJavaBefore9()) {
       agentParent = null; // bootstrap
     } else {
       // platform classloader is parent of system in java 9+
@@ -372,6 +374,10 @@ public class TracingAgent {
     return false;
   }
 
+  private static boolean isJavaBefore9() {
+    return System.getProperty("java.version").startsWith("1.");
+  }
+
   /**
    * Main entry point.
    *