Fix failing tests
Add TracingAgent to list of bootstrap class
Fix renaming tests
Fix JMXFetch path splitting
MODIFY
dd-java-agent/agent-bootstrap/src/main/java/datadog/trace/bootstrap/DatadogClassLoader.java
dd-java-agent/agent-bootstrap/src/main/java/datadog/trace/bootstrap/DatadogClassLoader.java
@@ -105,7 +105,7 @@ public class DatadogClassLoader extends URLClassLoader {
}
public BootstrapClassLoaderProxy(final URL[] urls) {
- super(urls);
+ super(urls, null);
}
@Override

MODIFY
dd-java-agent/agent-jmxfetch/src/main/java/datadog/trace/agent/jmxfetch/JMXFetch.java
dd-java-agent/agent-jmxfetch/src/main/java/datadog/trace/agent/jmxfetch/JMXFetch.java
@@ -155,7 +155,15 @@ public class JMXFetch {
integrationName.add(config.replace(".yaml", ""));
if (Config.get().isJmxFetchIntegrationEnabled(integrationName, false)) {
final URL resource = JMXFetch.class.getResource("metricconfigs/" + config);
- result.add(resource.getPath().split("\\.jar!/")[1]);
+
+ // jar!/ means a file internal to a jar, only add the part after if it exists
+ final String path = resource.getPath();
+ final int filenameIndex = path.indexOf("jar!/");
+ if (filenameIndex != -1) {
+ result.add(path.substring(filenameIndex + 5));
+ } else {
+ result.add(path.substring(1));
+ }
}
}
return result;

MODIFY
dd-java-agent/agent-tooling/src/main/java/datadog/trace/agent/tooling/Constants.java
dd-java-agent/agent-tooling/src/main/java/datadog/trace/agent/tooling/Constants.java
@@ -14,6 +14,7 @@ public final class Constants {
*/
public static final String[] BOOTSTRAP_PACKAGE_PREFIXES = {
"datadog.slf4j",
+ "datadog.trace.agent.TracingAgent",
"datadog.trace.api",
"datadog.trace.bootstrap",
"datadog.trace.context",

MODIFY
dd-java-agent/src/test/groovy/datadog/trace/agent/integration/classloading/ShadowPackageRenamingTest.groovy
dd-java-agent/src/test/groovy/datadog/trace/agent/integration/classloading/ShadowPackageRenamingTest.groovy
@@ -14,23 +14,23 @@ class ShadowPackageRenamingTest extends Specification {
final Class<?> ddClass =
IntegrationTestUtils.getAgentClassLoader()
.loadClass("datadog.trace.agent.tooling.AgentInstaller")
- final String userGuava =
- MapMaker.getProtectionDomain().getCodeSource().getLocation().getFile()
- final String agentGuavaDep =
+ final URL userGuava =
+ MapMaker.getProtectionDomain().getCodeSource().getLocation()
+ final URL agentGuavaDep =
ddClass
.getClassLoader()
.loadClass("com.google.common.collect.MapMaker")
.getProtectionDomain()
.getCodeSource()
.getLocation()
- .getFile()
- final String agentSource =
- ddClass.getProtectionDomain().getCodeSource().getLocation().getFile()
+ final URL agentSource =
+ ddClass.getProtectionDomain().getCodeSource().getLocation()
expect:
- agentSource.matches(".*/agent-tooling-and-instrumentation[^/]*.jar")
+ agentSource.getFile() == "/"
+ agentSource.getProtocol() == "x-internal-jar"
agentSource == agentGuavaDep
- agentSource != userGuava
+ agentSource.getFile() != userGuava.getFile()
}
def "java getLogger rewritten to safe logger"() {

Fix failing tests

Add TracingAgent to list of bootstrap class
Fix renaming tests
Fix JMXFetch path splitting