ni-ze 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_r230548745
##########
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:
From the comment of the source code:
Appends all annotations of the instrumented method but not the annotations
of the method's receiver type if such a type exists.
----------------------------------------------------------------
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:
[email protected]
With regards,
Apache Git Services