zifeihan commented on issue #6456:
URL: https://github.com/apache/skywalking/issues/6456#issuecomment-787394620
> I have one question about the following code:
>
> ```java
> public class CallbackConstructorInterceptor implements
InstanceConstructorInterceptor {
>
> @Override
> public void onConstruct(EnhancedInstance objInst, Object[]
allArguments) {
> Callback callback = (Callback) allArguments[0];
> CallbackCache cache;
> if (null != objInst.getSkyWalkingDynamicField()) {
> cache = (CallbackCache) objInst.getSkyWalkingDynamicField();
> } else {
> cache = new CallbackCache();
> }
> cache.setCallback(callback);
> objInst.setSkyWalkingDynamicField(cache);
> }
> }
> ```
>
> In `KafkaTemplateCallbackInstrumentation`,
`CallbackConstructorInterceptor` is registerred as constructor interceptor for
`org.apache.kafka.clients.producer.KafkaProducer$InterceptorCallback`. Since
`onConstruct` is called after `KafkaProducer$InterceptorCallback`'s origin
constructor invocation, I think that `objInst.getSkyWalkingDynamicField()`
always return `null`.
>
> Under what conditions `objInst.getSkyWalkingDynamicField()` is not `null`?
@yaojingguo Regarding this code, I agree with you. I think here,
objInst.getSkyWalkingDynamicField() is always null. Do you have an environment
to simulate it?
----------------------------------------------------------------
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]