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/11/12 07:12:47 UTC

[GitHub] candyleer commented on a change in pull request #1875: Correct overriding parent class methods, when method parameters have annotations.More details to see the issue #1740

candyleer commented on a change in pull request #1875: Correct overriding parent class methods,when method parameters have annotations.More details to see the issue #1740
URL: https://github.com/apache/incubator-skywalking/pull/1875#discussion_r232551479
 
 

 ##########
 File path: apm-sniffer/apm-agent-core/src/main/java/org/apache/skywalking/apm/agent/core/plugin/interceptor/enhance/ClassEnhancePluginDefine.java
 ##########
 @@ -142,26 +145,26 @@
             for (InstanceMethodsInterceptPoint instanceMethodsInterceptPoint : instanceMethodsInterceptPoints) {
                 String interceptor = instanceMethodsInterceptPoint.getMethodsInterceptor();
                 if (StringUtil.isEmpty(interceptor)) {
-                    throw new EnhanceException("no InstanceMethodsAroundInterceptor define to enhance class " + enhanceOriginClassName);
+                    throw new EnhanceException("no InstanceMethodsAroundInterceptor define to enhance class " + typeDescription.getTypeName());
                 }
 
                 if (instanceMethodsInterceptPoint.isOverrideArgs()) {
-                    newClassBuilder =
-                        newClassBuilder.method(not(isStatic()).and(instanceMethodsInterceptPoint.getMethodsMatcher()))
-                            .intercept(
-                                MethodDelegation.withDefaultConfiguration()
-                                    .withBinders(
-                                        Morph.Binder.install(OverrideCallable.class)
-                                    )
-                                    .to(new InstMethodsInterWithOverrideArgs(interceptor, classLoader))
-                            );
+                    newClassBuilder = newClassBuilder.method(isDeclaredBy(typeDescription)
+                            .and(not(isStatic()).and(instanceMethodsInterceptPoint.getMethodsMatcher())))
+                            .intercept(MethodDelegation.withDefaultConfiguration().withBinders(Morph.Binder.install(OverrideCallable.class)).to(new InstMethodsInterWithOverrideArgs(interceptor, classLoader)))
+
+                            .method(not(isDeclaredBy(typeDescription))
+                                    .and(not(isStatic()).and(instanceMethodsInterceptPoint.getMethodsMatcher())))
+                            .intercept(MethodDelegation.withDefaultConfiguration().withBinders(Morph.Binder.install(OverrideCallable.class)).to(new InstMethodsInterWithOverrideArgs(interceptor, classLoader)))
+                            .attribute(MethodAttributeAppender.ForInstrumentedMethod.EXCLUDING_RECEIVER);
 
 Review comment:
   `This config in my test env is copying  parent annotations to child method`, it is definitely  solved issue #1724, but #1632 also exists, demo also fail to execute (this config will change spring url mapping map value, not recommend), so I think we should enhance method those only declared by one class but not inherit cause may have some bad effect.

----------------------------------------------------------------
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