in apm-sniffer/apm-agent-core/src/main/java/org/apache/skywalking/apm/agent/core/plugin/bootstrap/template/v2/InstanceMethodInterV2WithOverrideArgsTemplate.java [66:125]
public static Object intercept(@This Object obj, @AllArguments Object[] allArguments, @Morph OverrideCallable zuper,
@Origin Method method) throws Throwable {
EnhancedInstance targetObject = (EnhancedInstance) obj;
prepare();
long interceptorTimeCost = 0L;
long startTimeOfMethodBeforeInter = System.nanoTime();
MethodInvocationContext context = new MethodInvocationContext();
try {
if (INTERCEPTOR != null) {
INTERCEPTOR.beforeMethod(targetObject, method, allArguments, method.getParameterTypes(), context);
}
} catch (Throwable t) {
if (LOGGER != null) {
LOGGER.error(t, "class[{}] before method[{}] intercept failure", obj.getClass(), method.getName());
}
PLUGIN_SO11Y.error(PLUGIN_NAME, INTERCEPTOR_TYPE);
}
interceptorTimeCost += System.nanoTime() - startTimeOfMethodBeforeInter;
Object ret = null;
try {
if (!context.isContinue()) {
ret = context._ret();
} else {
ret = zuper.call(allArguments);
}
} catch (Throwable t) {
long startTimeOfMethodHandleExceptionInter = System.nanoTime();
try {
if (INTERCEPTOR != null) {
INTERCEPTOR.handleMethodException(targetObject, method, allArguments, method.getParameterTypes(), t, context);
}
} catch (Throwable t2) {
if (LOGGER != null) {
LOGGER.error(t2, "class[{}] handle method[{}] exception failure", obj.getClass(), method.getName());
}
PLUGIN_SO11Y.error(PLUGIN_NAME, INTERCEPTOR_TYPE);
}
interceptorTimeCost += System.nanoTime() - startTimeOfMethodHandleExceptionInter;
throw t;
} finally {
long startTimeOfMethodAfterInter = System.nanoTime();
try {
if (INTERCEPTOR != null) {
ret = INTERCEPTOR.afterMethod(targetObject, method, allArguments, method.getParameterTypes(), ret, context);
}
} catch (Throwable t) {
if (LOGGER != null) {
LOGGER.error(t, "class[{}] after method[{}] intercept failure", obj.getClass(), method.getName());
}
PLUGIN_SO11Y.error(PLUGIN_NAME, INTERCEPTOR_TYPE);
}
interceptorTimeCost += System.nanoTime() - startTimeOfMethodAfterInter;
}
PLUGIN_SO11Y.duration(interceptorTimeCost);
return ret;
}