Remove unnecessary constant (#2941)
This commit is contained in:
parent
1dda1e2659
commit
1ce90bb4cd
|
@ -21,27 +21,5 @@ public final class Constants {
|
||||||
"io.opentelemetry.javaagent.instrumentation.api",
|
"io.opentelemetry.javaagent.instrumentation.api",
|
||||||
};
|
};
|
||||||
|
|
||||||
// This is used in IntegrationTestUtils.java
|
|
||||||
public static final String[] AGENT_PACKAGE_PREFIXES = {
|
|
||||||
"io.opentelemetry.instrumentation.api",
|
|
||||||
// guava
|
|
||||||
"com.google.auto",
|
|
||||||
"com.google.common",
|
|
||||||
"com.google.thirdparty.publicsuffix",
|
|
||||||
// bytebuddy
|
|
||||||
"net.bytebuddy",
|
|
||||||
"org.yaml.snakeyaml",
|
|
||||||
// disruptor
|
|
||||||
"com.lmax.disruptor",
|
|
||||||
// okHttp
|
|
||||||
"okhttp3",
|
|
||||||
"okio",
|
|
||||||
"jnr",
|
|
||||||
"org.objectweb.asm",
|
|
||||||
"com.kenai",
|
|
||||||
// Custom RxJava Utility
|
|
||||||
"rx.__OpenTelemetryTracingUtil",
|
|
||||||
};
|
|
||||||
|
|
||||||
private Constants() {}
|
private Constants() {}
|
||||||
}
|
}
|
||||||
|
|
|
@ -11,6 +11,29 @@ import io.opentelemetry.javaagent.IntegrationTestUtils
|
||||||
import spock.lang.Specification
|
import spock.lang.Specification
|
||||||
|
|
||||||
class ShadowPackageRenamingTest extends Specification {
|
class ShadowPackageRenamingTest extends Specification {
|
||||||
|
|
||||||
|
|
||||||
|
static final String[] AGENT_PACKAGE_PREFIXES = [
|
||||||
|
"io.opentelemetry.instrumentation.api",
|
||||||
|
// guava
|
||||||
|
"com.google.auto",
|
||||||
|
"com.google.common",
|
||||||
|
"com.google.thirdparty.publicsuffix",
|
||||||
|
// bytebuddy
|
||||||
|
"net.bytebuddy",
|
||||||
|
"org.yaml.snakeyaml",
|
||||||
|
// disruptor
|
||||||
|
"com.lmax.disruptor",
|
||||||
|
// okHttp
|
||||||
|
"okhttp3",
|
||||||
|
"okio",
|
||||||
|
"jnr",
|
||||||
|
"org.objectweb.asm",
|
||||||
|
"com.kenai",
|
||||||
|
// Custom RxJava Utility
|
||||||
|
"rx.__OpenTelemetryTracingUtil"
|
||||||
|
]
|
||||||
|
|
||||||
def "agent dependencies renamed"() {
|
def "agent dependencies renamed"() {
|
||||||
setup:
|
setup:
|
||||||
Class<?> clazz =
|
Class<?> clazz =
|
||||||
|
@ -49,7 +72,6 @@ class ShadowPackageRenamingTest extends Specification {
|
||||||
ClassPath bootstrapClasspath = ClassPath.from(IntegrationTestUtils.getBootstrapProxy())
|
ClassPath bootstrapClasspath = ClassPath.from(IntegrationTestUtils.getBootstrapProxy())
|
||||||
Set<String> bootstrapClasses = new HashSet<>()
|
Set<String> bootstrapClasses = new HashSet<>()
|
||||||
String[] bootstrapPrefixes = IntegrationTestUtils.getBootstrapPackagePrefixes()
|
String[] bootstrapPrefixes = IntegrationTestUtils.getBootstrapPackagePrefixes()
|
||||||
String[] agentPrefixes = IntegrationTestUtils.getAgentPackagePrefixes()
|
|
||||||
List<String> badBootstrapPrefixes = []
|
List<String> badBootstrapPrefixes = []
|
||||||
for (ClassPath.ClassInfo info : bootstrapClasspath.getAllClasses()) {
|
for (ClassPath.ClassInfo info : bootstrapClasspath.getAllClasses()) {
|
||||||
bootstrapClasses.add(info.getName())
|
bootstrapClasses.add(info.getName())
|
||||||
|
@ -76,13 +98,15 @@ class ShadowPackageRenamingTest extends Specification {
|
||||||
|
|
||||||
List<ClassPath.ClassInfo> agentDuplicateClassFile = new ArrayList<>()
|
List<ClassPath.ClassInfo> agentDuplicateClassFile = new ArrayList<>()
|
||||||
List<String> badAgentPrefixes = []
|
List<String> badAgentPrefixes = []
|
||||||
|
// TODO (trask) agentClasspath.getAllClasses() is empty
|
||||||
|
// so this part of the test doesn't verify what it thinks it is verifying
|
||||||
for (ClassPath.ClassInfo classInfo : agentClasspath.getAllClasses()) {
|
for (ClassPath.ClassInfo classInfo : agentClasspath.getAllClasses()) {
|
||||||
if (bootstrapClasses.contains(classInfo.getName())) {
|
if (bootstrapClasses.contains(classInfo.getName())) {
|
||||||
agentDuplicateClassFile.add(classInfo)
|
agentDuplicateClassFile.add(classInfo)
|
||||||
}
|
}
|
||||||
boolean goodPrefix = false
|
boolean goodPrefix = false
|
||||||
for (int i = 0; i < agentPrefixes.length; ++i) {
|
for (int i = 0; i < AGENT_PACKAGE_PREFIXES.length; ++i) {
|
||||||
if (classInfo.getName().startsWith(agentPrefixes[i])) {
|
if (classInfo.getName().startsWith(AGENT_PACKAGE_PREFIXES[i])) {
|
||||||
goodPrefix = true
|
goodPrefix = true
|
||||||
break
|
break
|
||||||
}
|
}
|
||||||
|
|
|
@ -137,14 +137,6 @@ public class IntegrationTestUtils {
|
||||||
return (String[]) f.get(null);
|
return (String[]) f.get(null);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static String[] getAgentPackagePrefixes() throws Exception {
|
|
||||||
Field f =
|
|
||||||
getAgentClassLoader()
|
|
||||||
.loadClass("io.opentelemetry.javaagent.tooling.Constants")
|
|
||||||
.getField("AGENT_PACKAGE_PREFIXES");
|
|
||||||
return (String[]) f.get(null);
|
|
||||||
}
|
|
||||||
|
|
||||||
private static String getAgentArgument() {
|
private static String getAgentArgument() {
|
||||||
RuntimeMXBean runtimeMxBean = ManagementFactory.getRuntimeMXBean();
|
RuntimeMXBean runtimeMxBean = ManagementFactory.getRuntimeMXBean();
|
||||||
for (String arg : runtimeMxBean.getInputArguments()) {
|
for (String arg : runtimeMxBean.getInputArguments()) {
|
||||||
|
|
Loading…
Reference in New Issue