BewareMyPower commented on code in PR #254:
URL: https://github.com/apache/pulsar-client-cpp/pull/254#discussion_r1169425027
##########
lib/c/c_Consumer.cc:
##########
@@ -73,6 +73,21 @@ pulsar_result
pulsar_consumer_batch_receive(pulsar_consumer_t *consumer, pulsar_
return (pulsar_result)res;
}
+void pulsar_consumer_batch_receive_async(pulsar_consumer_t *consumer,
pulsar_batch_receive_callback callback,
+ void *ctx) {
+ consumer->consumer.batchReceiveAsync([callback, ctx](pulsar::Result
result, pulsar::Messages messages) {
+ pulsar_messages_t *msgs = nullptr;
+ if (callback && result == pulsar::ResultOk) {
+ msgs = new pulsar_messages_t;
+ msgs->messages.resize(messages.size());
+ for (size_t i = 0; i < messages.size(); i++) {
+ msgs->messages[i].message = messages[i];
+ }
+ }
+ callback((pulsar_result)result, msgs, ctx);
Review Comment:
You checked `callback` before but did not check `callback` here. Then, when
`callback` is null, it will crash.
You should remove the null check for `callback` before or add the null check
here. It's determined by whether your API allows a null callback.
--
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.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]