You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@pulsar.apache.org by xy...@apache.org on 2022/08/29 19:04:53 UTC
[pulsar] branch master updated: Fix wrong consumers size: execute `callback` before executing `readerCreatedCallback_`. (#17325)
This is an automated email from the ASF dual-hosted git repository.
xyz pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/pulsar.git
The following commit(s) were added to refs/heads/master by this push:
new 3bc50a4277a Fix wrong consumers size: execute `callback` before executing `readerCreatedCallback_`. (#17325)
3bc50a4277a is described below
commit 3bc50a4277a102c1683041d7311ebd2266f32d9c
Author: Cong Zhao <zh...@apache.org>
AuthorDate: Tue Aug 30 03:04:44 2022 +0800
Fix wrong consumers size: execute `callback` before executing `readerCreatedCallback_`. (#17325)
Fixes #14848
### Motivation
We should execute `callback` before executing `readerCreatedCallback_`, otherwise, we may get the wrong consumers size. More see:
https://github.com/apache/pulsar/blob/e23d312c04da1d82d35f9e2faf8a446f8e8a4eeb/pulsar-client-cpp/lib/ReaderImpl.cc#L84-L92
https://github.com/apache/pulsar/blob/c48a3243287c7d775459b6437d9f4b24ed44cf4c/pulsar-client-cpp/lib/ClientImpl.cc#L250-L254
### Modifications
execute `callback` before executing `readerCreatedCallback_`
---
pulsar-client-cpp/lib/ReaderImpl.cc | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/pulsar-client-cpp/lib/ReaderImpl.cc b/pulsar-client-cpp/lib/ReaderImpl.cc
index c660c01ab2a..5f78068228f 100644
--- a/pulsar-client-cpp/lib/ReaderImpl.cc
+++ b/pulsar-client-cpp/lib/ReaderImpl.cc
@@ -84,8 +84,8 @@ void ReaderImpl::start(const MessageId& startMessageId,
consumer_->getConsumerCreatedFuture().addListener(
[this, self, callback](Result result, const ConsumerImplBaseWeakPtr& weakConsumerPtr) {
if (result == ResultOk) {
- readerCreatedCallback_(result, Reader(self));
callback(weakConsumerPtr);
+ readerCreatedCallback_(result, Reader(self));
} else {
readerCreatedCallback_(result, {});
}