diff --git a/apm-sniffer/apm-sdk-plugin/spring-plugins/mvc-annotation-commons/src/main/java/org/apache/skywalking/apm/plugin/spring/mvc/commons/interceptor/RequestMappingMethodInterceptor.java b/apm-sniffer/apm-sdk-plugin/spring-plugins/mvc-annotation-commons/src/main/java/org/apache/skywalking/apm/plugin/spring/mvc/commons/interceptor/RequestMappingMethodInterceptor.java index 38f939717afa..208800d27f47 100644 --- a/apm-sniffer/apm-sdk-plugin/spring-plugins/mvc-annotation-commons/src/main/java/org/apache/skywalking/apm/plugin/spring/mvc/commons/interceptor/RequestMappingMethodInterceptor.java +++ b/apm-sniffer/apm-sdk-plugin/spring-plugins/mvc-annotation-commons/src/main/java/org/apache/skywalking/apm/plugin/spring/mvc/commons/interceptor/RequestMappingMethodInterceptor.java @@ -18,6 +18,7 @@ package org.apache.skywalking.apm.plugin.spring.mvc.commons.interceptor; +import org.springframework.core.annotation.AnnotationUtils; import org.springframework.web.bind.annotation.RequestMapping; import java.lang.reflect.Method; @@ -32,7 +33,7 @@ public class RequestMappingMethodInterceptor extends AbstractMethodInterceptor { @Override public String getRequestURL(Method method) { String requestURL = ""; - RequestMapping methodRequestMapping = method.getAnnotation(RequestMapping.class); + RequestMapping methodRequestMapping = AnnotationUtils.getAnnotation(method, RequestMapping.class); if (methodRequestMapping.value().length > 0) { requestURL = methodRequestMapping.value()[0]; } else if (methodRequestMapping.path().length > 0) { @@ -43,7 +44,7 @@ public String getRequestURL(Method method) { @Override public String getAcceptedMethodTypes(Method method) { - RequestMapping methodRequestMapping = method.getAnnotation(RequestMapping.class); + RequestMapping methodRequestMapping = AnnotationUtils.getAnnotation(method, RequestMapping.class); StringBuilder methodTypes = new StringBuilder(); if (methodRequestMapping.method().length > 0) { methodTypes.append("{"); diff --git a/apm-sniffer/apm-sdk-plugin/spring-plugins/mvc-annotation-commons/src/main/java/org/apache/skywalking/apm/plugin/spring/mvc/commons/interceptor/RestMappingMethodInterceptor.java b/apm-sniffer/apm-sdk-plugin/spring-plugins/mvc-annotation-commons/src/main/java/org/apache/skywalking/apm/plugin/spring/mvc/commons/interceptor/RestMappingMethodInterceptor.java index 086e0595013c..d122604ddf35 100644 --- a/apm-sniffer/apm-sdk-plugin/spring-plugins/mvc-annotation-commons/src/main/java/org/apache/skywalking/apm/plugin/spring/mvc/commons/interceptor/RestMappingMethodInterceptor.java +++ b/apm-sniffer/apm-sdk-plugin/spring-plugins/mvc-annotation-commons/src/main/java/org/apache/skywalking/apm/plugin/spring/mvc/commons/interceptor/RestMappingMethodInterceptor.java @@ -18,6 +18,7 @@ package org.apache.skywalking.apm.plugin.spring.mvc.commons.interceptor; +import org.springframework.core.annotation.AnnotationUtils; import org.springframework.web.bind.annotation.*; import java.lang.reflect.Method; @@ -34,11 +35,11 @@ public class RestMappingMethodInterceptor extends AbstractMethodInterceptor { @Override public String getRequestURL(Method method) { String requestURL = ""; - GetMapping getMapping = method.getAnnotation(GetMapping.class); - PostMapping postMapping = method.getAnnotation(PostMapping.class); - PutMapping putMapping = method.getAnnotation(PutMapping.class); - DeleteMapping deleteMapping = method.getAnnotation(DeleteMapping.class); - PatchMapping patchMapping = method.getAnnotation(PatchMapping.class); + GetMapping getMapping = AnnotationUtils.getAnnotation(method, GetMapping.class); + PostMapping postMapping = AnnotationUtils.getAnnotation(method, PostMapping.class); + PutMapping putMapping = AnnotationUtils.getAnnotation(method, PutMapping.class); + DeleteMapping deleteMapping = AnnotationUtils.getAnnotation(method, DeleteMapping.class); + PatchMapping patchMapping = AnnotationUtils.getAnnotation(method, PatchMapping.class); if (getMapping != null) { if (getMapping.value().length > 0) { requestURL = getMapping.value()[0];