You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@skywalking.apache.org by wu...@apache.org on 2018/07/31 14:37:34 UTC
[incubator-skywalking] branch 6.0 updated: Fix #1488: Fix NPE when
the targetAop class is null (#1507)
This is an automated email from the ASF dual-hosted git repository.
wusheng pushed a commit to branch 6.0
in repository https://gitbox.apache.org/repos/asf/incubator-skywalking.git
The following commit(s) were added to refs/heads/6.0 by this push:
new 5eea1ae Fix #1488: Fix NPE when the targetAop class is null (#1507)
5eea1ae is described below
commit 5eea1ae7670b58acaa7278ee3b3e730235d17bc7
Author: Xin,Zhang <zh...@apache.org>
AuthorDate: Tue Jul 31 22:36:40 2018 +0800
Fix #1488: Fix NPE when the targetAop class is null (#1507)
---
.../patch/AopExpressionMatchInterceptor.java | 27 +++++++++++-----------
1 file changed, 14 insertions(+), 13 deletions(-)
diff --git a/apm-sniffer/apm-sdk-plugin/spring-plugins/core-patch/src/main/java/org/apache/skywalking/apm/plugin/spring/patch/AopExpressionMatchInterceptor.java b/apm-sniffer/apm-sdk-plugin/spring-plugins/core-patch/src/main/java/org/apache/skywalking/apm/plugin/spring/patch/AopExpressionMatchInterceptor.java
index 9f46731..5c99a88 100644
--- a/apm-sniffer/apm-sdk-plugin/spring-plugins/core-patch/src/main/java/org/apache/skywalking/apm/plugin/spring/patch/AopExpressionMatchInterceptor.java
+++ b/apm-sniffer/apm-sdk-plugin/spring-plugins/core-patch/src/main/java/org/apache/skywalking/apm/plugin/spring/patch/AopExpressionMatchInterceptor.java
@@ -15,17 +15,15 @@
* limitations under the License.
*/
-
package org.apache.skywalking.apm.plugin.spring.patch;
-import org.apache.skywalking.apm.agent.core.plugin.interceptor.enhance.EnhancedInstance;
-import org.apache.skywalking.apm.agent.core.plugin.interceptor.enhance.MethodInterceptResult;
-import org.apache.skywalking.apm.agent.core.plugin.interceptor.enhance.StaticMethodsAroundInterceptor;
-
import java.lang.reflect.Method;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
+import org.apache.skywalking.apm.agent.core.plugin.interceptor.enhance.EnhancedInstance;
+import org.apache.skywalking.apm.agent.core.plugin.interceptor.enhance.MethodInterceptResult;
+import org.apache.skywalking.apm.agent.core.plugin.interceptor.enhance.StaticMethodsAroundInterceptor;
/**
* {@link AopExpressionMatchInterceptor} check if the method is match the enhanced method
@@ -42,30 +40,33 @@ public class AopExpressionMatchInterceptor implements StaticMethodsAroundInterce
}
@Override
- public void beforeMethod(Class clazz, Method method, Object[] allArguments, Class<?>[] parameterTypes, MethodInterceptResult result) {
+ public void beforeMethod(Class clazz, Method method, Object[] allArguments, Class<?>[] parameterTypes,
+ MethodInterceptResult result) {
}
@Override
- public Object afterMethod(Class clazz, Method method, Object[] allArguments, Class<?>[] parameterTypes, Object ret) {
- Method targetAopMethod = (Method) allArguments[1];
- Class<?> targetAopClass = (Class<?>) allArguments[2];
- if (EnhancedInstance.class.isAssignableFrom(targetAopClass) && isEnhancedMethod(targetAopMethod)) {
+ public Object afterMethod(Class clazz, Method method, Object[] allArguments, Class<?>[] parameterTypes,
+ Object ret) {
+ Method targetAopMethod = (Method)allArguments[1];
+ Class<?> targetAopClass = (Class<?>)allArguments[2];
+ if (targetAopClass != null && EnhancedInstance.class.isAssignableFrom(targetAopClass) && isEnhancedMethod(targetAopMethod)) {
return false;
}
return ret;
}
@Override
- public void handleMethodException(Class clazz, Method method, Object[] allArguments, Class<?>[] parameterTypes, Throwable t) {
+ public void handleMethodException(Class clazz, Method method, Object[] allArguments, Class<?>[] parameterTypes,
+ Throwable t) {
}
private boolean isEnhancedMethod(Method targetMethod) {
for (Method method : methods) {
if (method.getName().equals(targetMethod.getName())
- && method.getReturnType().equals(targetMethod.getReturnType())
- && equalParamTypes(method.getParameterTypes(), targetMethod.getParameterTypes())) {
+ && method.getReturnType().equals(targetMethod.getReturnType())
+ && equalParamTypes(method.getParameterTypes(), targetMethod.getParameterTypes())) {
return true;
}
}