You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@pulsar.apache.org by xi...@apache.org on 2022/12/13 11:03:20 UTC

[pulsar] 01/02: Fix wrong consumers size: execute `callback` before executing `readerCreatedCallback_`. (#17325)

This is an automated email from the ASF dual-hosted git repository.

xiangying pushed a commit to branch branch-2.10
in repository https://gitbox.apache.org/repos/asf/pulsar.git

commit 2672446db571abbf7ea0ffd6a2a6e297cd2065c6
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_`
    
    (cherry picked from commit 3bc50a4277a102c1683041d7311ebd2266f32d9c)
---
 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, {});
             }