Fix failing tests

Add TracingAgent to list of bootstrap class
Fix renaming tests
Fix JMXFetch path splitting
This commit is contained in:
Laplie Anderson 2019-07-30 15:27:47 -04:00
parent c275143eae
commit c41536cbe2
4 changed files with 19 additions and 10 deletions

View File

@ -105,7 +105,7 @@ public class DatadogClassLoader extends URLClassLoader {
} }
public BootstrapClassLoaderProxy(final URL[] urls) { public BootstrapClassLoaderProxy(final URL[] urls) {
super(urls); super(urls, null);
} }
@Override @Override

View File

@ -155,7 +155,15 @@ public class JMXFetch {
integrationName.add(config.replace(".yaml", "")); integrationName.add(config.replace(".yaml", ""));
if (Config.get().isJmxFetchIntegrationEnabled(integrationName, false)) { if (Config.get().isJmxFetchIntegrationEnabled(integrationName, false)) {
final URL resource = JMXFetch.class.getResource("metricconfigs/" + config); 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; return result;

View File

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

View File

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