提交 5b451c8d 编写于 作者: A ascrutae

Merge remote-tracking branch 'origin/master'

# Conflicts:
#	skywalking-collector/skywalking-sdk-plugin/tomcat-7.x-8.x-plugin/src/main/java/com/ai/cloud/skywalking/plugin/tomcat78x/TomcatPluginInterceptor.java
......@@ -4,16 +4,9 @@ import com.ai.cloud.skywalking.logging.LogManager;
import com.ai.cloud.skywalking.logging.Logger;
import com.ai.cloud.skywalking.plugin.interceptor.EnhancedClassInstanceContext;
import com.ai.cloud.skywalking.plugin.interceptor.loader.InterceptorInstanceLoader;
import net.bytebuddy.ByteBuddy;
import net.bytebuddy.dynamic.loading.ClassLoadingStrategy;
import net.bytebuddy.implementation.bind.annotation.*;
import sun.tools.jar.resources.jar;
import java.io.BufferedInputStream;
import java.io.ByteArrayOutputStream;
import java.io.IOException;
import java.lang.reflect.Method;
import java.security.ProtectionDomain;
import java.util.concurrent.Callable;
/**
......@@ -42,16 +35,17 @@ public class ClassInstanceMethodsInterceptor {
} catch (Throwable t) {
logger.error("class[{}] before method[{}] intercept failue:{}", new Object[] {obj.getClass(), method.getName(), t.getMessage()}, t);
}
if (!result.isContinue()) {
return result._ret();
}
Object ret = null;
try {
ret = zuper.call();
if (!result.isContinue()) {
ret = result._ret();
}else {
ret = zuper.call();
}
} catch (Throwable t) {
try {
interceptor.handleMethodException(t, instanceContext, interceptorContext, ret);
interceptor.handleMethodException(t, instanceContext, interceptorContext);
} catch (Throwable t2) {
logger.error("class[{}] handle method[{}] exception failue:{}", new Object[] {obj.getClass(), method.getName(), t2.getMessage()}, t2);
}
......
......@@ -36,16 +36,18 @@ public class ClassStaticMethodsInterceptor {
} catch (Throwable t) {
logger.error("class[{}] before static method[{}] intercept failue:{}", new Object[] {clazz, method.getName(), t.getMessage()}, t);
}
if (!result.isContinue()) {
return result._ret();
}
Object ret = null;
try {
ret = zuper.call();
if (!result.isContinue()) {
ret = result._ret();
}else {
ret = zuper.call();
}
} catch (Throwable t) {
try {
interceptor.handleMethodException(t, interceptorContext, ret);
interceptor.handleMethodException(t, interceptorContext);
} catch (Throwable t2) {
logger.error("class[{}] handle static method[{}] exception failue:{}", new Object[] {clazz, method.getName(), t2.getMessage()}, t2);
}
......
......@@ -9,5 +9,5 @@ public interface InstanceMethodsAroundInterceptor {
public Object afterMethod(EnhancedClassInstanceContext context, InstanceMethodInvokeContext interceptorContext, Object ret);
public void handleMethodException(Throwable t, EnhancedClassInstanceContext context, InstanceMethodInvokeContext interceptorContext, Object ret);
public void handleMethodException(Throwable t, EnhancedClassInstanceContext context, InstanceMethodInvokeContext interceptorContext);
}
package com.ai.cloud.skywalking.plugin.interceptor.enhance;
/**
* 通过拦截器的before方法,指定被拦截方法的返回值,不再调用原始方法取得返回值
*/
public class MethodInterceptResult {
private boolean isContinue = true;
......
......@@ -6,5 +6,5 @@ public interface StaticMethodsAroundInterceptor {
public Object afterMethod(MethodInvokeContext interceptorContext, Object ret);
public void handleMethodException(Throwable t, MethodInvokeContext interceptorContext, Object ret);
public void handleMethodException(Throwable t, MethodInvokeContext interceptorContext);
}
......@@ -27,7 +27,7 @@ public class TestAroundInterceptor implements InstanceMethodsAroundInterceptor {
}
@Override
public void handleMethodException(Throwable t, EnhancedClassInstanceContext context, InstanceMethodInvokeContext interceptorContext, Object ret) {
public void handleMethodException(Throwable t, EnhancedClassInstanceContext context, InstanceMethodInvokeContext interceptorContext) {
}
}
......@@ -26,8 +26,7 @@ public class TestAroundInterceptor implements InstanceMethodsAroundInterceptor {
}
@Override
public void handleMethodException(Throwable t, EnhancedClassInstanceContext context,
InstanceMethodInvokeContext interceptorContext, Object ret) {
public void handleMethodException(Throwable t, EnhancedClassInstanceContext context, InstanceMethodInvokeContext interceptorContext) {
// TODO Auto-generated method stub
}
......
......@@ -18,8 +18,7 @@ public class TestStaticAroundInterceptor implements StaticMethodsAroundIntercept
}
@Override
public void handleMethodException(Throwable t,
MethodInvokeContext interceptorContext, Object ret) {
public void handleMethodException(Throwable t, MethodInvokeContext interceptorContext) {
// TODO Auto-generated method stub
}
......
......@@ -94,8 +94,7 @@ public class MonitorFilterInterceptor implements InstanceMethodsAroundIntercepto
}
@Override
public void handleMethodException(Throwable t, EnhancedClassInstanceContext context,
InstanceMethodInvokeContext interceptorContext, Object ret) {
public void handleMethodException(Throwable t, EnhancedClassInstanceContext context, InstanceMethodInvokeContext interceptorContext) {
dealException(t, context);
}
......
......@@ -63,9 +63,7 @@ public class HttpClientExecuteInterceptor implements InstanceMethodsAroundInterc
}
@Override
public void handleMethodException(Throwable t,
EnhancedClassInstanceContext context,
InstanceMethodInvokeContext interceptorContext, Object ret) {
public void handleMethodException(Throwable t, EnhancedClassInstanceContext context, InstanceMethodInvokeContext interceptorContext) {
Object[] allArguments = interceptorContext.allArguments();
if (allArguments[0] == null || allArguments[1] == null) {
// illegal args, can't trace. ignore.
......
......@@ -43,7 +43,7 @@ public abstract class JedisBaseInterceptor extends SimpleObjectFirstInvokeInterc
}
@Override
public void handleMethodException(Throwable t, EnhancedClassInstanceContext context, InstanceMethodInvokeContext interceptorContext, Object ret) {
public void handleMethodException(Throwable t, EnhancedClassInstanceContext context, InstanceMethodInvokeContext interceptorContext) {
rpcClientInvokeMonitor.occurException(t);
}
}
......@@ -68,6 +68,6 @@ public class TomcatPluginInterceptor implements InstanceMethodsAroundInterceptor
@Override
public void handleMethodException(Throwable t, EnhancedClassInstanceContext context, InstanceMethodInvokeContext interceptorContext, Object ret) {
new RPCServerInvokeMonitor().occurException(t);
// DO Nothing
}
}
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册