Skip to content

Commit

Permalink
fix: spring annotation inheritance problem #3847 (#3886)
Browse files Browse the repository at this point in the history
  • Loading branch information
carrypann authored and wu-sheng committed Nov 19, 2019
1 parent 6ffd927 commit 7e889d3
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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) {
Expand All @@ -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("{");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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];
Expand Down

0 comments on commit 7e889d3

Please sign in to comment.