don't cache classloaders which can be skipped by name (DataDog/dd-trace-java#1732)

This commit is contained in:
Richard Startin 2020-07-31 16:27:20 +01:00 committed by Trask Stalnaker
parent f7b32e4fd5
commit a012143ac0
1 changed files with 5 additions and 2 deletions

View File

@ -67,6 +67,9 @@ public final class ClassLoaderMatcher {
// Don't skip bootstrap loader
return false;
}
if (canSkipClassLoaderByName(cl)) {
return true;
}
Boolean v = skipCache.getIfPresent(cl);
if (v != null) {
return v;
@ -79,12 +82,12 @@ public final class ClassLoaderMatcher {
// and we don't want to introduce the concept of the tooling code depending on whether or not
// a particular instrumentation is active (mainly because this particular use case doesn't
// seem to justify introducing either of these new concepts)
v = shouldSkipClass(cl) || !delegatesToBootstrap(cl);
v = !delegatesToBootstrap(cl);
skipCache.put(cl, v);
return v;
}
private static boolean shouldSkipClass(ClassLoader loader) {
private static boolean canSkipClassLoaderByName(ClassLoader loader) {
switch (loader.getClass().getName()) {
case "org.codehaus.groovy.runtime.callsite.CallSiteClassLoader":
case "sun.reflect.DelegatingClassLoader":