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 2020/01/23 10:04:01 UTC

[GitHub] [skywalking] dfkjadkfj opened a new pull request #4278: Solve the problem of matching annotations of MVC plugin interface met…

dfkjadkfj opened a new pull request #4278: Solve the problem of matching annotations of MVC plugin interface met…
URL: https://github.com/apache/skywalking/pull/4278
 
 
   
   - Why submit this pull request?
   - [ ] Bug fix
   - [ ] New feature provided
   - [x] Improve performance
   
   - Related issues
     #3847 how to enhance method with @RequestMapping annotation declared in interface?
   ___
   ### New feature or improvement
   - Describe the details and related test reports.
   

----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to 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

[GitHub] [skywalking] kezhenxu94 commented on a change in pull request #4278: Solve the problem of matching annotations of MVC plugin interface met…

Posted by GitBox <gi...@apache.org>.
kezhenxu94 commented on a change in pull request #4278: Solve the problem of matching annotations of MVC plugin interface met…
URL: https://github.com/apache/skywalking/pull/4278#discussion_r370124140
 
 

 ##########
 File path: apm-sniffer/apm-agent-core/src/main/java/org/apache/skywalking/apm/agent/core/plugin/match/MethodInheritsDeclaringAnnotationMatcher.java
 ##########
 @@ -0,0 +1,101 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ */
+package org.apache.skywalking.apm.agent.core.plugin.match;
+
+import net.bytebuddy.build.HashCodeAndEqualsPlugin;
+import net.bytebuddy.description.annotation.AnnotationList;
+import net.bytebuddy.description.annotation.AnnotationSource;
+import net.bytebuddy.description.method.MethodDescription;
+import net.bytebuddy.description.method.MethodList;
+import net.bytebuddy.description.method.ParameterList;
+import net.bytebuddy.description.type.TypeDefinition;
+import net.bytebuddy.description.type.TypeDescription;
+import net.bytebuddy.description.type.TypeList;
+import net.bytebuddy.matcher.CollectionItemMatcher;
+import net.bytebuddy.matcher.ElementMatcher;
+
+import java.util.Objects;
+
+import static net.bytebuddy.matcher.ElementMatchers.annotationType;
+
+/**
+ * @description: Matching used to match method annotations, Can match annotations on interface methods
+ * @auther: jialong  by 2020-01-23 15:41
 
 Review comment:
   typo `@author`, and please remove the `:`

----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to 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

[GitHub] [skywalking] wu-sheng commented on issue #4278: Make MVC plugin support inherited annotations from interface

Posted by GitBox <gi...@apache.org>.
wu-sheng commented on issue #4278: Make MVC plugin support inherited annotations from interface
URL: https://github.com/apache/skywalking/pull/4278#issuecomment-581028040
 
 
   Welcome to be the 201st contributor in this repo.

----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to 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

[GitHub] [skywalking] wu-sheng commented on issue #4278: Solve the problem of matching annotations of MVC plugin interface met…

Posted by GitBox <gi...@apache.org>.
wu-sheng commented on issue #4278: Solve the problem of matching annotations of MVC plugin interface met…
URL: https://github.com/apache/skywalking/pull/4278#issuecomment-581000521
 
 
   ```
   [INFO] Running org.apache.skywalking.apm.agent.core.plugin.bytebuddy.MethodInheritanceAnnotationMatcherTest
   [ERROR] Tests run: 1, Failures: 1, Errors: 0, Skipped: 0, Time elapsed: 0.09 s <<< FAILURE! - in org.apache.skywalking.apm.agent.core.plugin.bytebuddy.MethodInheritanceAnnotationMatcherTest
   [ERROR] testMatch(org.apache.skywalking.apm.agent.core.plugin.bytebuddy.MethodInheritanceAnnotationMatcherTest)  Time elapsed: 0.09 s  <<< FAILURE!
   java.lang.AssertionError
   	at org.apache.skywalking.apm.agent.core.plugin.bytebuddy.MethodInheritanceAnnotationMatcherTest.testMatch(MethodInheritanceAnnotationMatcherTest.java:44)
   ```
   
   Test fail, please recheck. https://github.com/apache/skywalking/pull/4278/checks?check_run_id=420562649

----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to 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

[GitHub] [skywalking] wu-sheng commented on a change in pull request #4278: Solve the problem of matching annotations of MVC plugin interface met…

Posted by GitBox <gi...@apache.org>.
wu-sheng commented on a change in pull request #4278: Solve the problem of matching annotations of MVC plugin interface met…
URL: https://github.com/apache/skywalking/pull/4278#discussion_r373763635
 
 

 ##########
 File path: apm-sniffer/apm-agent-core/src/main/java/org/apache/skywalking/apm/agent/core/plugin/match/MethodInheritanceAnnotationMatcher.java
 ##########
 @@ -0,0 +1,101 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ */
+package org.apache.skywalking.apm.agent.core.plugin.match;
+
+import net.bytebuddy.build.HashCodeAndEqualsPlugin;
+import net.bytebuddy.description.annotation.AnnotationList;
+import net.bytebuddy.description.annotation.AnnotationSource;
+import net.bytebuddy.description.method.MethodDescription;
+import net.bytebuddy.description.method.MethodList;
+import net.bytebuddy.description.method.ParameterList;
+import net.bytebuddy.description.type.TypeDefinition;
+import net.bytebuddy.description.type.TypeDescription;
+import net.bytebuddy.description.type.TypeList;
+import net.bytebuddy.matcher.CollectionItemMatcher;
+import net.bytebuddy.matcher.ElementMatcher;
+
+import java.util.Objects;
+
+import static net.bytebuddy.matcher.ElementMatchers.annotationType;
+
+/**
+ * Matching used to match method annotations, Can match annotations on interface methods
+ * @author jialong
+ */
+@HashCodeAndEqualsPlugin.Enhance
+public class MethodInheritanceAnnotationMatcher<T extends MethodDescription> extends ElementMatcher.Junction.AbstractBase<T> {
+    /**
+     * The matcher to be applied to the provided annotation list.
+     */
+    private final ElementMatcher<? super AnnotationList> matcher;
+
+    /**
+     * Creates a new matcher for the annotations of an annotated element.
+     *
+     * @param matcher The matcher to be applied to the provided annotation list.
+     */
+    public MethodInheritanceAnnotationMatcher(ElementMatcher<? super AnnotationList> matcher) {
+        this.matcher = matcher;
+    }
+
+    @Override
+    public boolean matches(T target) {
+        if (matcher.matches(target.getDeclaredAnnotations())) {
+            return true;
+        }
+        String name = target.getName();
+        ParameterList<?> parameters = target.getParameters();
+
+        TypeDefinition declaringType = target.getDeclaringType();
+        return recursiveMatches(declaringType, name, parameters);
+    }
+
+
+    private boolean recursiveMatches(TypeDefinition typeDefinition, String methodName, ParameterList<?> parameters) {
+        TypeList.Generic interfaces = typeDefinition.getInterfaces();
+        for (TypeDescription.Generic implInterface : interfaces) {
+            if (recursiveMatches(implInterface, methodName, parameters)) {
+                return true;
+            }
+            MethodList<MethodDescription.InGenericShape> declaredMethods = implInterface.getDeclaredMethods();
 
 Review comment:
   Is this right? Should this be out of `for` loop?

----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to 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

[GitHub] [skywalking] kezhenxu94 merged pull request #4278: Make MVC plugin support inherited annotations from interface

Posted by GitBox <gi...@apache.org>.
kezhenxu94 merged pull request #4278: Make MVC plugin support inherited annotations from interface
URL: https://github.com/apache/skywalking/pull/4278
 
 
   

----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to 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

[GitHub] [skywalking] kezhenxu94 commented on a change in pull request #4278: Solve the problem of matching annotations of MVC plugin interface met…

Posted by GitBox <gi...@apache.org>.
kezhenxu94 commented on a change in pull request #4278: Solve the problem of matching annotations of MVC plugin interface met…
URL: https://github.com/apache/skywalking/pull/4278#discussion_r370124391
 
 

 ##########
 File path: apm-sniffer/apm-agent-core/src/main/java/org/apache/skywalking/apm/agent/core/plugin/match/MethodInheritsDeclaringAnnotationMatcher.java
 ##########
 @@ -0,0 +1,101 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ */
+package org.apache.skywalking.apm.agent.core.plugin.match;
+
+import net.bytebuddy.build.HashCodeAndEqualsPlugin;
+import net.bytebuddy.description.annotation.AnnotationList;
+import net.bytebuddy.description.annotation.AnnotationSource;
+import net.bytebuddy.description.method.MethodDescription;
+import net.bytebuddy.description.method.MethodList;
+import net.bytebuddy.description.method.ParameterList;
+import net.bytebuddy.description.type.TypeDefinition;
+import net.bytebuddy.description.type.TypeDescription;
+import net.bytebuddy.description.type.TypeList;
+import net.bytebuddy.matcher.CollectionItemMatcher;
+import net.bytebuddy.matcher.ElementMatcher;
+
+import java.util.Objects;
+
+import static net.bytebuddy.matcher.ElementMatchers.annotationType;
+
+/**
+ * @description: Matching used to match method annotations, Can match annotations on interface methods
 
 Review comment:
   remove `@description`, it's not a valid JavaDoc tag

----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to 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

[GitHub] [skywalking] kezhenxu94 commented on a change in pull request #4278: Solve the problem of matching annotations of MVC plugin interface met…

Posted by GitBox <gi...@apache.org>.
kezhenxu94 commented on a change in pull request #4278: Solve the problem of matching annotations of MVC plugin interface met…
URL: https://github.com/apache/skywalking/pull/4278#discussion_r370124731
 
 

 ##########
 File path: apm-sniffer/apm-agent-core/src/test/java/org/apache/skywalking/apm/agent/core/plugin/bytebuddy/MethodInheritsDeclaringAnnotationMatcherTest.java
 ##########
 @@ -0,0 +1,89 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ */
+package org.apache.skywalking.apm.agent.core.plugin.bytebuddy;
+
+import net.bytebuddy.description.annotation.AnnotationSource;
+import net.bytebuddy.description.method.MethodDescription;
+import net.bytebuddy.matcher.ElementMatcher;
+import org.junit.Assert;
+import org.junit.Test;
+
+import java.lang.annotation.Documented;
+import java.lang.annotation.ElementType;
+import java.lang.annotation.Retention;
+import java.lang.annotation.RetentionPolicy;
+import java.lang.annotation.Target;
+
+import static net.bytebuddy.matcher.ElementMatchers.named;
+import static org.apache.skywalking.apm.agent.core.plugin.match.MethodInheritsDeclaringAnnotationMatcher.isInheritsAnnotatedWith;
+
+/**
+ * @description:
+ * @auther: jialong  by 2020-01-23 16:09
 
 Review comment:
   ditto

----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to 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

[GitHub] [skywalking] kezhenxu94 commented on a change in pull request #4278: Solve the problem of matching annotations of MVC plugin interface met…

Posted by GitBox <gi...@apache.org>.
kezhenxu94 commented on a change in pull request #4278: Solve the problem of matching annotations of MVC plugin interface met…
URL: https://github.com/apache/skywalking/pull/4278#discussion_r371192135
 
 

 ##########
 File path: apm-sniffer/apm-agent-core/src/main/java/org/apache/skywalking/apm/agent/core/plugin/match/MethodInheritanceAnnotationMatcher.java
 ##########
 @@ -0,0 +1,101 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ */
+package org.apache.skywalking.apm.agent.core.plugin.match;
+
+import net.bytebuddy.build.HashCodeAndEqualsPlugin;
+import net.bytebuddy.description.annotation.AnnotationList;
+import net.bytebuddy.description.annotation.AnnotationSource;
+import net.bytebuddy.description.method.MethodDescription;
+import net.bytebuddy.description.method.MethodList;
+import net.bytebuddy.description.method.ParameterList;
+import net.bytebuddy.description.type.TypeDefinition;
+import net.bytebuddy.description.type.TypeDescription;
+import net.bytebuddy.description.type.TypeList;
+import net.bytebuddy.matcher.CollectionItemMatcher;
+import net.bytebuddy.matcher.ElementMatcher;
+
+import java.util.Objects;
+
+import static net.bytebuddy.matcher.ElementMatchers.annotationType;
+
+/**
+ * Matching used to match method annotations, Can match annotations on interface methods
+ * @auther jialong
 
 Review comment:
   Still, `@auther` is not a valid JavaDoc
   
   ```suggestion
    * @author jialong
   ```

----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to 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

[GitHub] [skywalking] wu-sheng commented on a change in pull request #4278: Solve the problem of matching annotations of MVC plugin interface met…

Posted by GitBox <gi...@apache.org>.
wu-sheng commented on a change in pull request #4278: Solve the problem of matching annotations of MVC plugin interface met…
URL: https://github.com/apache/skywalking/pull/4278#discussion_r371118184
 
 

 ##########
 File path: apm-sniffer/apm-agent-core/src/main/java/org/apache/skywalking/apm/agent/core/plugin/match/MethodInheritsDeclaringAnnotationMatcher.java
 ##########
 @@ -0,0 +1,101 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ */
+package org.apache.skywalking.apm.agent.core.plugin.match;
+
+import net.bytebuddy.build.HashCodeAndEqualsPlugin;
+import net.bytebuddy.description.annotation.AnnotationList;
+import net.bytebuddy.description.annotation.AnnotationSource;
+import net.bytebuddy.description.method.MethodDescription;
+import net.bytebuddy.description.method.MethodList;
+import net.bytebuddy.description.method.ParameterList;
+import net.bytebuddy.description.type.TypeDefinition;
+import net.bytebuddy.description.type.TypeDescription;
+import net.bytebuddy.description.type.TypeList;
+import net.bytebuddy.matcher.CollectionItemMatcher;
+import net.bytebuddy.matcher.ElementMatcher;
+
+import java.util.Objects;
+
+import static net.bytebuddy.matcher.ElementMatchers.annotationType;
+
+/**
+ * Matching used to match method annotations, Can match annotations on interface methods
+ * @auther jialong
+ */
+@HashCodeAndEqualsPlugin.Enhance
+public class MethodInheritsDeclaringAnnotationMatcher<T extends MethodDescription> extends ElementMatcher.Junction.AbstractBase<T> {
 
 Review comment:
   Should rename to `MethodInheritanceAnnotationMatcher`

----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to 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

[GitHub] [skywalking] wu-sheng commented on a change in pull request #4278: Solve the problem of matching annotations of MVC plugin interface met…

Posted by GitBox <gi...@apache.org>.
wu-sheng commented on a change in pull request #4278: Solve the problem of matching annotations of MVC plugin interface met…
URL: https://github.com/apache/skywalking/pull/4278#discussion_r371118102
 
 

 ##########
 File path: apm-sniffer/apm-agent-core/src/main/java/org/apache/skywalking/apm/agent/core/plugin/match/MethodInheritsDeclaringAnnotationMatcher.java
 ##########
 @@ -0,0 +1,101 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ */
+package org.apache.skywalking.apm.agent.core.plugin.match;
+
+import net.bytebuddy.build.HashCodeAndEqualsPlugin;
+import net.bytebuddy.description.annotation.AnnotationList;
+import net.bytebuddy.description.annotation.AnnotationSource;
+import net.bytebuddy.description.method.MethodDescription;
+import net.bytebuddy.description.method.MethodList;
+import net.bytebuddy.description.method.ParameterList;
+import net.bytebuddy.description.type.TypeDefinition;
+import net.bytebuddy.description.type.TypeDescription;
+import net.bytebuddy.description.type.TypeList;
+import net.bytebuddy.matcher.CollectionItemMatcher;
+import net.bytebuddy.matcher.ElementMatcher;
+
+import java.util.Objects;
+
+import static net.bytebuddy.matcher.ElementMatchers.annotationType;
+
+/**
+ * Matching used to match method annotations, Can match annotations on interface methods
+ * @auther jialong
+ */
+@HashCodeAndEqualsPlugin.Enhance
+public class MethodInheritsDeclaringAnnotationMatcher<T extends MethodDescription> extends ElementMatcher.Junction.AbstractBase<T> {
+    /**
+     * The matcher to be applied to the provided annotation list.
+     */
+    private final ElementMatcher<? super AnnotationList> matcher;
+
+    /**
+     * Creates a new matcher for the annotations of an annotated element.
+     *
+     * @param matcher The matcher to be applied to the provided annotation list.
+     */
+    public MethodInheritsDeclaringAnnotationMatcher(ElementMatcher<? super AnnotationList> matcher) {
+        this.matcher = matcher;
+    }
+
+    @Override
+    public boolean matches(T target) {
+        if (matcher.matches(target.getDeclaredAnnotations())) {
+            return true;
+        }
+        String name = target.getName();
+        ParameterList<?> parameters = target.getParameters();
+
+        TypeDefinition declaringType = target.getDeclaringType();
+        return recursiveMatches(declaringType, name, parameters);
+    }
+
+
+    private boolean recursiveMatches(TypeDefinition typeDefinition, String methodName, ParameterList<?> parameters) {
+        TypeList.Generic interfaces = typeDefinition.getInterfaces();
+        for (TypeDescription.Generic implInterface : interfaces) {
+            if (recursiveMatches(implInterface, methodName, parameters)) {
+                return true;
+            }
+            MethodList<MethodDescription.InGenericShape> declaredMethods = implInterface.getDeclaredMethods();
+            for (MethodDescription declaredMethod : declaredMethods) {
+                if (Objects.equals(declaredMethod.getName(), methodName) && parameterEquals(parameters, declaredMethod.getParameters())) {
+                    return matcher.matches(declaredMethod.getDeclaredAnnotations());
+                }
+            }
+        }
+        return false;
+    }
+
+
+    private boolean parameterEquals(ParameterList<?> source, ParameterList<?> impl) {
+        if (source.size() != impl.size()) {
+            return false;
+        }
+        for (int i = 0; i < source.size(); i++) {
+            if (!Objects.equals(source.get(i).getType(), impl.get(i).getType())) {
+                return false;
+            }
+        }
+        return true;
+    }
+
+    public static <T extends AnnotationSource> ElementMatcher.Junction<T> isInheritsAnnotatedWith(ElementMatcher<? super TypeDescription> matcher) {
 
 Review comment:
   Inherit is a verb. This method name should be `byMethodInheritanceAnnotationMatcher`

----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to 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

[GitHub] [skywalking] wu-sheng commented on a change in pull request #4278: Solve the problem of matching annotations of MVC plugin interface met…

Posted by GitBox <gi...@apache.org>.
wu-sheng commented on a change in pull request #4278: Solve the problem of matching annotations of MVC plugin interface met…
URL: https://github.com/apache/skywalking/pull/4278#discussion_r373763635
 
 

 ##########
 File path: apm-sniffer/apm-agent-core/src/main/java/org/apache/skywalking/apm/agent/core/plugin/match/MethodInheritanceAnnotationMatcher.java
 ##########
 @@ -0,0 +1,101 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ */
+package org.apache.skywalking.apm.agent.core.plugin.match;
+
+import net.bytebuddy.build.HashCodeAndEqualsPlugin;
+import net.bytebuddy.description.annotation.AnnotationList;
+import net.bytebuddy.description.annotation.AnnotationSource;
+import net.bytebuddy.description.method.MethodDescription;
+import net.bytebuddy.description.method.MethodList;
+import net.bytebuddy.description.method.ParameterList;
+import net.bytebuddy.description.type.TypeDefinition;
+import net.bytebuddy.description.type.TypeDescription;
+import net.bytebuddy.description.type.TypeList;
+import net.bytebuddy.matcher.CollectionItemMatcher;
+import net.bytebuddy.matcher.ElementMatcher;
+
+import java.util.Objects;
+
+import static net.bytebuddy.matcher.ElementMatchers.annotationType;
+
+/**
+ * Matching used to match method annotations, Can match annotations on interface methods
+ * @author jialong
+ */
+@HashCodeAndEqualsPlugin.Enhance
+public class MethodInheritanceAnnotationMatcher<T extends MethodDescription> extends ElementMatcher.Junction.AbstractBase<T> {
+    /**
+     * The matcher to be applied to the provided annotation list.
+     */
+    private final ElementMatcher<? super AnnotationList> matcher;
+
+    /**
+     * Creates a new matcher for the annotations of an annotated element.
+     *
+     * @param matcher The matcher to be applied to the provided annotation list.
+     */
+    public MethodInheritanceAnnotationMatcher(ElementMatcher<? super AnnotationList> matcher) {
+        this.matcher = matcher;
+    }
+
+    @Override
+    public boolean matches(T target) {
+        if (matcher.matches(target.getDeclaredAnnotations())) {
+            return true;
+        }
+        String name = target.getName();
+        ParameterList<?> parameters = target.getParameters();
+
+        TypeDefinition declaringType = target.getDeclaringType();
+        return recursiveMatches(declaringType, name, parameters);
+    }
+
+
+    private boolean recursiveMatches(TypeDefinition typeDefinition, String methodName, ParameterList<?> parameters) {
+        TypeList.Generic interfaces = typeDefinition.getInterfaces();
+        for (TypeDescription.Generic implInterface : interfaces) {
+            if (recursiveMatches(implInterface, methodName, parameters)) {
+                return true;
+            }
+            MethodList<MethodDescription.InGenericShape> declaredMethods = implInterface.getDeclaredMethods();
 
 Review comment:
   Is this right? Should this be out of `for` loop?

----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to 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

[GitHub] [skywalking] codecov-io commented on issue #4278: Solve the problem of matching annotations of MVC plugin interface met…

Posted by GitBox <gi...@apache.org>.
codecov-io commented on issue #4278: Solve the problem of matching annotations of MVC plugin interface met…
URL: https://github.com/apache/skywalking/pull/4278#issuecomment-581003475
 
 
   # [Codecov](https://codecov.io/gh/apache/skywalking/pull/4278?src=pr&el=h1) Report
   > :exclamation: No coverage uploaded for pull request base (`master@a1b309e`). [Click here to learn what that means](https://docs.codecov.io/docs/error-reference#section-missing-base-commit).
   > The diff coverage is `4.96%`.
   
   [![Impacted file tree graph](https://codecov.io/gh/apache/skywalking/pull/4278/graphs/tree.svg?width=650&token=qrILxY5yA8&height=150&src=pr)](https://codecov.io/gh/apache/skywalking/pull/4278?src=pr&el=tree)
   
   ```diff
   @@            Coverage Diff            @@
   ##             master    #4278   +/-   ##
   =========================================
     Coverage          ?   26.72%           
   =========================================
     Files             ?     1170           
     Lines             ?    25579           
     Branches          ?     3655           
   =========================================
     Hits              ?     6836           
     Misses            ?    18133           
     Partials          ?      610
   ```
   
   
   | [Impacted Files](https://codecov.io/gh/apache/skywalking/pull/4278?src=pr&el=tree) | Coverage Δ | |
   |---|---|---|
   | [...ng/apm/plugin/grpc/v1/OperationNameFormatUtil.java](https://codecov.io/gh/apache/skywalking/pull/4278/diff?src=pr&el=tree#diff-YXBtLXNuaWZmZXIvYXBtLXNkay1wbHVnaW4vZ3JwYy0xLngtcGx1Z2luL3NyYy9tYWluL2phdmEvb3JnL2FwYWNoZS9za3l3YWxraW5nL2FwbS9wbHVnaW4vZ3JwYy92MS9PcGVyYXRpb25OYW1lRm9ybWF0VXRpbC5qYXZh) | `0% <ø> (ø)` | |
   | [...ywalking/apm/plugin/avro/ResponderInterceptor.java](https://codecov.io/gh/apache/skywalking/pull/4278/diff?src=pr&el=tree#diff-YXBtLXNuaWZmZXIvYXBtLXNkay1wbHVnaW4vYXZyby1wbHVnaW4vc3JjL21haW4vamF2YS9vcmcvYXBhY2hlL3NreXdhbGtpbmcvYXBtL3BsdWdpbi9hdnJvL1Jlc3BvbmRlckludGVyY2VwdG9yLmphdmE=) | `0% <0%> (ø)` | |
   | [.../plugin/elasticsearch/query/MetricsQueryEsDAO.java](https://codecov.io/gh/apache/skywalking/pull/4278/diff?src=pr&el=tree#diff-b2FwLXNlcnZlci9zZXJ2ZXItc3RvcmFnZS1wbHVnaW4vc3RvcmFnZS1lbGFzdGljc2VhcmNoLXBsdWdpbi9zcmMvbWFpbi9qYXZhL29yZy9hcGFjaGUvc2t5d2Fsa2luZy9vYXAvc2VydmVyL3N0b3JhZ2UvcGx1Z2luL2VsYXN0aWNzZWFyY2gvcXVlcnkvTWV0cmljc1F1ZXJ5RXNEQU8uamF2YQ==) | `0% <0%> (ø)` | |
   | [...plugin/grpc/v1/client/BlockingCallInterceptor.java](https://codecov.io/gh/apache/skywalking/pull/4278/diff?src=pr&el=tree#diff-YXBtLXNuaWZmZXIvYXBtLXNkay1wbHVnaW4vZ3JwYy0xLngtcGx1Z2luL3NyYy9tYWluL2phdmEvb3JnL2FwYWNoZS9za3l3YWxraW5nL2FwbS9wbHVnaW4vZ3JwYy92MS9jbGllbnQvQmxvY2tpbmdDYWxsSW50ZXJjZXB0b3IuamF2YQ==) | `0% <0%> (ø)` | |
   | [...g/apm/plugin/grpc/v1/client/ClientInterceptor.java](https://codecov.io/gh/apache/skywalking/pull/4278/diff?src=pr&el=tree#diff-YXBtLXNuaWZmZXIvYXBtLXNkay1wbHVnaW4vZ3JwYy0xLngtcGx1Z2luL3NyYy9tYWluL2phdmEvb3JnL2FwYWNoZS9za3l3YWxraW5nL2FwbS9wbHVnaW4vZ3JwYy92MS9jbGllbnQvQ2xpZW50SW50ZXJjZXB0b3IuamF2YQ==) | `0% <0%> (ø)` | |
   | [.../skywalking/apm/plugin/avro/SWServerRPCPlugin.java](https://codecov.io/gh/apache/skywalking/pull/4278/diff?src=pr&el=tree#diff-YXBtLXNuaWZmZXIvYXBtLXNkay1wbHVnaW4vYXZyby1wbHVnaW4vc3JjL21haW4vamF2YS9vcmcvYXBhY2hlL3NreXdhbGtpbmcvYXBtL3BsdWdpbi9hdnJvL1NXU2VydmVyUlBDUGx1Z2luLmphdmE=) | `0% <0%> (ø)` | |
   | [...g/apm/plugin/grpc/v1/client/TracingClientCall.java](https://codecov.io/gh/apache/skywalking/pull/4278/diff?src=pr&el=tree#diff-YXBtLXNuaWZmZXIvYXBtLXNkay1wbHVnaW4vZ3JwYy0xLngtcGx1Z2luL3NyYy9tYWluL2phdmEvb3JnL2FwYWNoZS9za3l3YWxraW5nL2FwbS9wbHVnaW4vZ3JwYy92MS9jbGllbnQvVHJhY2luZ0NsaWVudENhbGwuamF2YQ==) | `0% <0%> (ø)` | |
   | [.../storage/plugin/jdbc/h2/dao/H2MetricsQueryDAO.java](https://codecov.io/gh/apache/skywalking/pull/4278/diff?src=pr&el=tree#diff-b2FwLXNlcnZlci9zZXJ2ZXItc3RvcmFnZS1wbHVnaW4vc3RvcmFnZS1qZGJjLWhpa2FyaWNwLXBsdWdpbi9zcmMvbWFpbi9qYXZhL29yZy9hcGFjaGUvc2t5d2Fsa2luZy9vYXAvc2VydmVyL3N0b3JhZ2UvcGx1Z2luL2pkYmMvaDIvZGFvL0gyTWV0cmljc1F1ZXJ5REFPLmphdmE=) | `0% <0%> (ø)` | |
   | [...king/oap/server/core/query/MetricQueryService.java](https://codecov.io/gh/apache/skywalking/pull/4278/diff?src=pr&el=tree#diff-b2FwLXNlcnZlci9zZXJ2ZXItY29yZS9zcmMvbWFpbi9qYXZhL29yZy9hcGFjaGUvc2t5d2Fsa2luZy9vYXAvc2VydmVyL2NvcmUvcXVlcnkvTWV0cmljUXVlcnlTZXJ2aWNlLmphdmE=) | `0% <0%> (ø)` | |
   | [...1/server/AbstractServerImplBuilderInterceptor.java](https://codecov.io/gh/apache/skywalking/pull/4278/diff?src=pr&el=tree#diff-YXBtLXNuaWZmZXIvYXBtLXNkay1wbHVnaW4vZ3JwYy0xLngtcGx1Z2luL3NyYy9tYWluL2phdmEvb3JnL2FwYWNoZS9za3l3YWxraW5nL2FwbS9wbHVnaW4vZ3JwYy92MS9zZXJ2ZXIvQWJzdHJhY3RTZXJ2ZXJJbXBsQnVpbGRlckludGVyY2VwdG9yLmphdmE=) | `0% <0%> (ø)` | |
   | ... and [11 more](https://codecov.io/gh/apache/skywalking/pull/4278/diff?src=pr&el=tree-more) | |
   
   ------
   
   [Continue to review full report at Codecov](https://codecov.io/gh/apache/skywalking/pull/4278?src=pr&el=continue).
   > **Legend** - [Click here to learn more](https://docs.codecov.io/docs/codecov-delta)
   > `Δ = absolute <relative> (impact)`, `ø = not affected`, `? = missing data`
   > Powered by [Codecov](https://codecov.io/gh/apache/skywalking/pull/4278?src=pr&el=footer). Last update [a1b309e...b06b78c](https://codecov.io/gh/apache/skywalking/pull/4278?src=pr&el=lastupdated). Read the [comment docs](https://docs.codecov.io/docs/pull-request-comments).
   

----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to 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

[GitHub] [skywalking] dfkjadkfj commented on issue #4278: Solve the problem of matching annotations of MVC plugin interface met…

Posted by GitBox <gi...@apache.org>.
dfkjadkfj commented on issue #4278: Solve the problem of matching annotations of MVC plugin interface met…
URL: https://github.com/apache/skywalking/pull/4278#issuecomment-577761177
 
 
   For this PR I updated the test case of spring-4.3.x-scenario, please review

----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to 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

[GitHub] [skywalking] dfkjadkfj commented on issue #4278: Solve the problem of matching annotations of MVC plugin interface met…

Posted by GitBox <gi...@apache.org>.
dfkjadkfj commented on issue #4278: Solve the problem of matching annotations of MVC plugin interface met…
URL: https://github.com/apache/skywalking/pull/4278#issuecomment-581001342
 
 
   Sorry for not communicating in a timely manner, I have found a mistake, and am now fixing it, and returned to the countryside in the New Year, the network is not very good

----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to 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

[GitHub] [skywalking] dfkjadkfj commented on a change in pull request #4278: Solve the problem of matching annotations of MVC plugin interface met…

Posted by GitBox <gi...@apache.org>.
dfkjadkfj commented on a change in pull request #4278: Solve the problem of matching annotations of MVC plugin interface met…
URL: https://github.com/apache/skywalking/pull/4278#discussion_r370222659
 
 

 ##########
 File path: apm-sniffer/apm-agent-core/src/main/java/org/apache/skywalking/apm/agent/core/plugin/match/MethodInheritsDeclaringAnnotationMatcher.java
 ##########
 @@ -0,0 +1,101 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ */
+package org.apache.skywalking.apm.agent.core.plugin.match;
+
+import net.bytebuddy.build.HashCodeAndEqualsPlugin;
+import net.bytebuddy.description.annotation.AnnotationList;
+import net.bytebuddy.description.annotation.AnnotationSource;
+import net.bytebuddy.description.method.MethodDescription;
+import net.bytebuddy.description.method.MethodList;
+import net.bytebuddy.description.method.ParameterList;
+import net.bytebuddy.description.type.TypeDefinition;
+import net.bytebuddy.description.type.TypeDescription;
+import net.bytebuddy.description.type.TypeList;
+import net.bytebuddy.matcher.CollectionItemMatcher;
+import net.bytebuddy.matcher.ElementMatcher;
+
+import java.util.Objects;
+
+import static net.bytebuddy.matcher.ElementMatchers.annotationType;
+
+/**
+ * @description: Matching used to match method annotations, Can match annotations on interface methods
+ * @auther: jialong  by 2020-01-23 15:41
 
 Review comment:
   Thanks for your correction

----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to 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