Catch and log instrumentation matcher exception
Catching instrumentation matcher exceptions at the Instrumenter level allows other, unrelated instrumentation to match.
This commit is contained in:
parent
d64b162539
commit
57e85d4a13
|
@ -80,7 +80,7 @@ public interface Instrumenter {
|
||||||
|
|
||||||
AgentBuilder.Identified.Extendable agentBuilder =
|
AgentBuilder.Identified.Extendable agentBuilder =
|
||||||
parentAgentBuilder
|
parentAgentBuilder
|
||||||
.type(typeMatcher(), classLoaderMatcher())
|
.type(safeTypeMatcher(typeMatcher()), classLoaderMatcher())
|
||||||
.and(new MuzzleMatcher())
|
.and(new MuzzleMatcher())
|
||||||
.transform(DDTransformers.defaultTransformers());
|
.transform(DDTransformers.defaultTransformers());
|
||||||
agentBuilder = injectHelperClasses(agentBuilder);
|
agentBuilder = injectHelperClasses(agentBuilder);
|
||||||
|
@ -88,6 +88,23 @@ public interface Instrumenter {
|
||||||
return agentBuilder.asDecorator();
|
return agentBuilder.asDecorator();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/** Wrap an ElementMatcher in a try-catch exception and log any exceptions. */
|
||||||
|
private ElementMatcher<? super TypeDescription> safeTypeMatcher(
|
||||||
|
final ElementMatcher<? super TypeDescription> instrumentationMatcher) {
|
||||||
|
return new ElementMatcher<TypeDescription>() {
|
||||||
|
@Override
|
||||||
|
public boolean matches(TypeDescription target) {
|
||||||
|
try {
|
||||||
|
return instrumentationMatcher.matches(target);
|
||||||
|
} catch (Exception e) {
|
||||||
|
log.debug(
|
||||||
|
"Instrumentation matcher unexpected exception: " + instrumentationPrimaryName, e);
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
private AgentBuilder.Identified.Extendable injectHelperClasses(
|
private AgentBuilder.Identified.Extendable injectHelperClasses(
|
||||||
AgentBuilder.Identified.Extendable agentBuilder) {
|
AgentBuilder.Identified.Extendable agentBuilder) {
|
||||||
final String[] helperClassNames = helperClassNames();
|
final String[] helperClassNames = helperClassNames();
|
||||||
|
|
Loading…
Reference in New Issue