Need to cache the boolean. The list can be taken later as debug is expected to be slower
This commit is contained in:
parent
75af71584c
commit
af67dfa720
|
@ -135,9 +135,9 @@ public interface Instrumenter {
|
||||||
if (null != muzzle) {
|
if (null != muzzle) {
|
||||||
final boolean isMatch = muzzle.matches(classLoader);
|
final boolean isMatch = muzzle.matches(classLoader);
|
||||||
if (!isMatch) {
|
if (!isMatch) {
|
||||||
final List<Reference.Mismatch> mismatches =
|
|
||||||
muzzle.getMismatchedReferenceSources(classLoader);
|
|
||||||
if (log.isDebugEnabled()) {
|
if (log.isDebugEnabled()) {
|
||||||
|
final List<Reference.Mismatch> mismatches =
|
||||||
|
muzzle.getMismatchedReferenceSources(classLoader);
|
||||||
log.debug(
|
log.debug(
|
||||||
"Instrumentation muzzled: {} -- {} on {}",
|
"Instrumentation muzzled: {} -- {} on {}",
|
||||||
instrumentationNames,
|
instrumentationNames,
|
||||||
|
|
|
@ -22,9 +22,8 @@ import net.bytebuddy.pool.TypePool;
|
||||||
|
|
||||||
/** Matches a set of references against a classloader. */
|
/** Matches a set of references against a classloader. */
|
||||||
@Slf4j
|
@Slf4j
|
||||||
public class ReferenceMatcher
|
public class ReferenceMatcher implements WeakMap.ValueSupplier<ClassLoader, Boolean> {
|
||||||
implements WeakMap.ValueSupplier<ClassLoader, List<Reference.Mismatch>> {
|
private final WeakMap<ClassLoader, Boolean> mismatchCache = newWeakMap();
|
||||||
private final WeakMap<ClassLoader, List<Reference.Mismatch>> mismatchCache = newWeakMap();
|
|
||||||
private final Reference[] references;
|
private final Reference[] references;
|
||||||
private final Set<String> helperClassNames;
|
private final Set<String> helperClassNames;
|
||||||
|
|
||||||
|
@ -52,6 +51,11 @@ public class ReferenceMatcher
|
||||||
loader = Utils.getBootstrapProxy();
|
loader = Utils.getBootstrapProxy();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
return mismatchCache.computeIfAbsent(loader, this);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Boolean get(final ClassLoader loader) {
|
||||||
final List<Mismatch> mismatches = new ArrayList<>(0);
|
final List<Mismatch> mismatches = new ArrayList<>(0);
|
||||||
|
|
||||||
for (final Reference reference : references) {
|
for (final Reference reference : references) {
|
||||||
|
@ -65,7 +69,6 @@ public class ReferenceMatcher
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
mismatchCache.put(loader, mismatches);
|
|
||||||
return mismatches.size() == 0;
|
return mismatches.size() == 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -80,11 +83,6 @@ public class ReferenceMatcher
|
||||||
loader = Utils.getBootstrapProxy();
|
loader = Utils.getBootstrapProxy();
|
||||||
}
|
}
|
||||||
|
|
||||||
return mismatchCache.computeIfAbsent(loader, this);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public List<Mismatch> get(final ClassLoader loader) {
|
|
||||||
final List<Mismatch> mismatches = new ArrayList<>(0);
|
final List<Mismatch> mismatches = new ArrayList<>(0);
|
||||||
|
|
||||||
for (final Reference reference : references) {
|
for (final Reference reference : references) {
|
||||||
|
|
Loading…
Reference in New Issue