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/19 05:05:17 UTC

[GitHub] honganan opened a new issue #1935: constructor intercept order issue

honganan opened a new issue #1935: constructor intercept order issue
URL: https://github.com/apache/incubator-skywalking/issues/1935
 
 
   Hi, I think there may be a bug in constructor intercept about execute order. According to the comments in class `InstanceConstructorInterceptor`, the interceptor will called before the origin constructor invocation. But when I test it I found my origin constructor called first, and then the interceptor `onConstruct` method.
   After check I found bytebuddy support both two orders, before or after. What makes the difference is `intercept(A.andThen(B))`(L30 ClassEnhancePluginDefine.java):
   1) origin constructor first, then the intercept method:
   ```java
   newClassBuilder = newClassBuilder.constructor(constructorInterceptPoint.getConstructorMatcher()).intercept(SuperMethodCall.INSTANCE
                       .andThen(MethodDelegation.withDefaultConfiguration()
                           .to(new ConstructorInter(constructorInterceptPoint.getConstructorInterceptor(), classLoader))
                       )
                   );
   ```
   2) the intercept method first, then the origin constructor
   ```java
   newClassBuilder = newClassBuilder.constructor(constructorInterceptPoint.getConstructorMatcher()).intercept(MethodDelegation.withDefaultConfiguration()
                       .to(new ConstructorInter(constructorInterceptPoint.getConstructorInterceptor(), classLoader))
                       .andThen(SuperMethodCall.INSTANCE)
                   );
   ```

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