yaojingguo opened a new issue #6481:
URL: https://github.com/apache/skywalking/issues/6481
Please answer these questions before submitting your issue.
- Why do you submit this issue?
- [ ] Question or discussion
- [X] Bug
- [ ] Requirement
- [ ] Feature or performance improvement
___
### Bug
- Which version of SkyWalking, OS, and JRE?
1. SkyWalking 8.4.0
1. OS: macOS 10.15.5
1. JDK: Oracle JDK 1.8.0_162
1. kafka_2.13-2.7.0 server
1. `spring-kafka:2.2.6.RELEASE` which depends on `kafka-clients:2.6.0`
- What happened?
Use the following to send a message to Kafka:
```
Future<RecordMetadata> result = kafkaProducer.send(record);
result.get();
```
After running the above code, I found the following exception in
`agent/logs/skywalking-api.log`:
```
ERROR 2021-03-03 23:40:36:098 kafka-producer-network-thread | producer-1
InstMethodsInter : class[class
org.apache.kafka.clients.producer.KafkaProducer$InterceptorCallback] before
method[onCompletion] intercept failure
java.lang.NullPointerException
at
org.apache.skywalking.apm.plugin.kafka.CallbackInterceptor.getSnapshot(CallbackInterceptor.java:83)
at
org.apache.skywalking.apm.plugin.kafka.CallbackInterceptor.beforeMethod(CallbackInterceptor.java:44)
at
org.apache.skywalking.apm.agent.core.plugin.interceptor.enhance.InstMethodsInter.intercept(InstMethodsInter.java:76)
at
org.apache.kafka.clients.producer.KafkaProducer$InterceptorCallback.onCompletion(KafkaProducer.java)
at
org.apache.kafka.clients.producer.internals.ProducerBatch.completeFutureAndFireCallbacks(ProducerBatch.java:228)
at
org.apache.kafka.clients.producer.internals.ProducerBatch.done(ProducerBatch.java:197)
at
org.apache.kafka.clients.producer.internals.Sender.completeBatch(Sender.java:653)
at
org.apache.kafka.clients.producer.internals.Sender.completeBatch(Sender.java:634)
at
org.apache.kafka.clients.producer.internals.Sender.handleProduceResponse(Sender.java:554)
at
org.apache.kafka.clients.producer.internals.Sender.lambda$sendProduceRequest$0(Sender.java:743)
at
org.apache.kafka.clients.ClientResponse.onComplete(ClientResponse.java:109)
at
org.apache.kafka.clients.NetworkClient.completeResponses(NetworkClient.java:566)
at org.apache.kafka.clients.NetworkClient.poll(NetworkClient.java:558)
at
org.apache.kafka.clients.producer.internals.Sender.runOnce(Sender.java:325)
at
org.apache.kafka.clients.producer.internals.Sender.run(Sender.java:240)
at java.lang.Thread.run(Thread.java:748)
```
___
### Requirement or improvement
If `KafkaProducer.send(record)` is used, there is no callback. So
`allArguments[0]` is `null` in `CallbackConstructorInterceptor.onConstruct`.
When `CallbackInterceptor.getSnapshot` executes, `cache.getCallback()` returns
`null`.
My first throught is to add null check for `cache.getCallback()` in
`CallbackInterceptor`s `beforeMethod` and `afterMethod` methods. If
`cache.getCallback()` is `null`, do nothing.
----------------------------------------------------------------
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]