You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@skywalking.apache.org by GitBox <gi...@apache.org> on 2018/07/31 14:36:44 UTC

[GitHub] wu-sheng closed pull request #1507: Fix #1488: Fix NPE when the targetAop class is null

wu-sheng closed pull request #1507: Fix #1488: Fix NPE when the targetAop class is null
URL: https://github.com/apache/incubator-skywalking/pull/1507
 
 
   

This is a PR merged from a forked repository.
As GitHub hides the original diff on merge, it is displayed below for
the sake of provenance:

As this is a foreign pull request (from a fork), the diff is supplied
below (as it won't show otherwise due to GitHub magic):

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 9f46731d0..5c99a8869 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 AopExpressionMatchInterceptor() {
     }
 
     @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;
             }
         }


 

----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
users@infra.apache.org


With regards,
Apache Git Services