Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: spring annotation inheritance problem #3847 #3886

Merged
merged 5 commits into from
Nov 19, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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