lhotari opened a new pull request #8326:
URL: https://github.com/apache/pulsar/pull/8326


   Fixes #8300
   
   ### Motivation
   
   Explained in #8300
   
   ### Modifications
   
   The futures returned by org.apache.pulsar.client.api.Reader.readNextAsync, 
org.apache.pulsar.client.api.Consumer.receiveAsync and 
org.apache.pulsar.client.api.Consumer.batchReceiveAsync methods 
   return a CompletableFuture that contains a "whenComplete" callback which 
handles CancellationException & TimeoutException . The callback action will 
remove the registered futures from the internal "pendingReceives" and 
"pendingBatchReceives" futures.
   The changes attempt to also against possible race conditions that could 
happen when cancellation and a message get received at the exactly same moment 
and the future removed from the queue has already been cancelled. 
   
   While adding unit tests, some minor refactoring was made to start adding a 
ClientTestFixtures class that would make it easier to share some test mocks 
that are used in the client internal unit tests. The intention of this change 
was to start lowering the barrier for adding better test coverage for further 
changes. 
   
   ### Verifying this change
   
   Unit tests have been added to verify that cancelling message & batch futures 
remove the future from the internal "pendingReceives" and 
"pendingBatchReceives" queues.
   
   ### Documentation
   
     - Does this pull request introduce a new feature? yes
     - If yes, how is the feature documented? JavaDocs (TBD in a follow-up 
commit to this PR)


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


Reply via email to