zifeihan commented on issue #6481:
URL: https://github.com/apache/skywalking/issues/6481#issuecomment-790258324
thanks for report this bug, by looking at the source code of different
versions, it was found that their processing logic did have a certain change,
which may caused the problem. other words, our `kafka-scenario` test not
covered this.
It is recommended to use another way to fix it, judge whether callback is
empty in `CallbackConstructorInterceptor`, like this
```
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);
}
}
}
```
I noticed that a similar judgment was made in kafka-client, like
```
private static class InterceptorCallback<K, V> implements Callback {
private final Callback userCallback;
private final ProducerInterceptors<K, V> interceptors;
private final TopicPartition tp;
private InterceptorCallback(Callback userCallback,
ProducerInterceptors<K, V> interceptors, TopicPartition tp) {
this.userCallback = userCallback;
this.interceptors = interceptors;
this.tp = tp;
}
public void onCompletion(RecordMetadata metadata, Exception
exception) {
metadata = metadata != null ? metadata : new
RecordMetadata(this.tp, -1L, -1L, -1L, -1L, -1, -1);
this.interceptors.onAcknowledgement(metadata, exception);
if (this.userCallback != null) {
this.userCallback.onCompletion(metadata, exception);
}
}
}
```
Is it convenient for you to improve the test content in `kafka-scenario`? If
not, I will improve `kafka-scenario` after you fix this bug.
----------------------------------------------------------------
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]