candyleer commented on issue #3035: NPE Aspect
URL: https://github.com/apache/skywalking/issues/3035#issuecomment-510539321
 
 
   Actually, this is a complex problem.
   1.the controller method modifier is `private` which is not recommend for 
controller, without skywalking agent it is working just because an accident, 
you can try add a `public` method in the controller ,you will see the 
`goodsExternalService ` is always `null` in private method.
   1.1 why the `goodsExternalService ` is always `null` in private method if 
add another `public` method?
     the reason is the controller is enhanced by cglib in spring ,in enhanced 
classes ,private method cannot get `goodsExternalService`
   1.2 why it can work in current version?
    the reason is the controller just have a method and is `private` and it is 
not match the `ascpect expression `,so the controller will not be enhanced by 
cglib in spring .
   
   2.why with skywalking agent it doesn't work?
   the reason is is have implement an interface `EnhanceInstance` and it have 
two default method `getSkywalkingField` and `setSkywalkingField` which modifier 
is `public` ,this match the aspect expression.so the controller will enhanced 
by cglib in spring .
   
   3.conclusion
   If the class is enhanced by cglib in spring .all `private` method will get  
`goodsExternalService` by null.
   
![image](https://user-images.githubusercontent.com/11530760/61064074-ac267680-a433-11e9-853e-49eb26794bce.png)
   
   
![image](https://user-images.githubusercontent.com/11530760/61064728-e80e0b80-a434-11e9-8f9b-62747bd96ba6.png)
   

----------------------------------------------------------------
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:
[email protected]


With regards,
Apache Git Services

Reply via email to