BewareMyPower opened a new pull request #14854:
URL: https://github.com/apache/pulsar/pull/14854


   Fixes #14848
   
   Fixes #14719
   
   ### Motivation
   
   #7793 introduced a `testReferenceLeak` to avoid cyclic referenece of the
   reader. However, it adds a unused field `readerImplWeakPtr_` only for
   tests. The access to this field is not thread safe that the write
   operation happens in `handleConsumerCreated` while the read operation
   can happen anywhere via the getter. So there is a little chance that
   `readerPtr` in `testReferenceLeak` doesn't point to the right object.
   
   In addition, we should only guarantee the reference count becomes 0
   after the producer, consumer or reader goes out of its scope. #14797
   adds a `ClientTest.testReferenceCount` but it's also flaky. It's caused
   by the shared pointer of `ProducerImpl` is published to another thread
   via `shared_from_this()` but the test has a strong expectation that the
   reference count is exactly 1.
   
   ### Modifications
   
   - Remove `readerImplWeakPtr_` from `ReaderImpl` and get the weak pointer
     from `Reader` directly by adding a method to `PulsarFriend`.
   - Add the check of reader's reference count to `testReferenceCount` and
     remove the redundant `testReferenceLeak`.
   - Instead of asserting the reference count of producer/consumer/reader
     is 1, just assume the it's greater than 0.


-- 
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]


Reply via email to