BewareMyPower opened a new pull request #10006: URL: https://github.com/apache/pulsar/pull/10006
### Motivation Currently C++ client support get topic name from both received message and its message id. However, for a consumer that subscribes a non-partitioned topic, getting topic name from received message id will cause segmentation fault. The C++ implementation of `Message::getTopicName` or `MessageId::getTopicName` requires the invocation of `Message::setTopicName`, which make the internal `std::string*` point to the topic string of the consumer. If `setTopicName` was not called, the `getTopicName` method would cause segmentation fault since a null pointer would be dereferenced. However, when the consumer creates single messages from the batched message, `setTopicName` was not called. ### Modifications - Use `setTopicName` for each single message when a consumer receives a batch. - Add related tests for all types of `Consumer`, including `ConsumerImpl`, `MultiTopicsConsumerImpl` and `PartitionedConsumerImpl`. ### Verifying this change - [ ] Make sure that the change passes the CI checks. This change added tests `ConsumerTest.testGetTopicNameFromReceivedMessage`. -- 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]
