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 2021/03/04 05:53:18 UTC

[GitHub] [skywalking] yaojingguo commented on issue #6481: NullPointerException when using KafkaProducer.send(record)

yaojingguo commented on issue #6481:
URL: https://github.com/apache/skywalking/issues/6481#issuecomment-790315417


   > Is it convenient for you to improve the test content in kafka-scenario? 
   
   I will have a try to improve kafka-scenario after I fix this bug.
   
   
   I think that you mean `null != callback` by writing `null == callback`:
   ```Java
   public class CallbackConstructorInterceptor implements InstanceConstructorInterceptor {
   
       @Override
       public void onConstruct(EnhancedInstance objInst, Object[] allArguments) {
           Callback callback = (Callback) allArguments[0];
           if (null == callback) {
               CallbackCache cache;
               if (null != objInst.getSkyWalkingDynamicField()) {
                   cache = (CallbackCache) objInst.getSkyWalkingDynamicField();
               } else {
                   cache = new CallbackCache();
               }
               cache.setCallback(callback);
               objInst.setSkyWalkingDynamicField(cache);
           }
       }
   }
   ```
   
   And I think that we should add a null check for `ContextManager.activeSpan()` in `CallbackInterceptor.handleMethodException`:
   
   ```java
   @Override
   public void handleMethodException(EnhancedInstance objInst, Method method, Object[] allArguments,
       Class<?>[] argumentsTypes, Throwable t) {
       ContextManager.activeSpan().log(t);
   }
   ```
   
   @zifeihan 


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