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 2019/04/17 03:49:25 UTC

[GitHub] [incubator-skywalking] honganan opened a new issue #1935: Executing order of constructor interception issue

honganan opened a new issue #1935: Executing order of constructor interception issue
URL: https://github.com/apache/incubator-skywalking/issues/1935
 
 
   Hi, I think there may be a bug in constructor interception about executing 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.
   what I found is bytebuddy supports both two orders, before or after. What makes the difference is `intercept(A.andThen(B))`, for example(refer to 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 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