BewareMyPower commented on code in PR #16969:
URL: https://github.com/apache/pulsar/pull/16969#discussion_r950064781
##########
pulsar-client-cpp/lib/MultiTopicsConsumerImpl.cc:
##########
@@ -125,33 +144,37 @@ Future<Result, Consumer>
MultiTopicsConsumerImpl::subscribeOneTopicAsync(const s
}
// subscribe for each partition, when all partitions completed, complete
promise
-
lookupServicePtr_->getPartitionMetadataAsync(topicName).addListener(std::bind(
- &MultiTopicsConsumerImpl::subscribeTopicPartitions,
shared_from_this(), std::placeholders::_1,
- std::placeholders::_2, topicName, subscriptionName_, conf_,
topicPromise));
+ Lock lock(mutex_);
+ auto entry = topicsPartitions_.find(topic);
+ lock.unlock();
Review Comment:
A simple modification might be
```c++
auto entry = topicsPartitions_.find(topic);
if (entry == topicsPartitions_.end()) {
lock.unlock();
/* get the partition metadata async... */
} else {
const int numPartitions = entry->second;
lock.unlock();
/* ... */
}
```
--
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]