codelipenghui commented on a change in pull request #8207:
URL: https://github.com/apache/pulsar/pull/8207#discussion_r500851629



##########
File path: 
pulsar-client/src/main/java/org/apache/pulsar/client/impl/ConsumerBase.java
##########
@@ -677,19 +677,16 @@ protected void notifyPendingBatchReceivedCallBack() {
         if (opBatchReceive == null || opBatchReceive.future == null) {
             return;
         }
-        notifyPendingBatchReceivedCallBack(opBatchReceive);
+        synchronized (incomingMessages) {

Review comment:
       Looks the 'synchronized' block is to protect the 
`notifyPendingBatchReceivedCallBack(opBatchReceive)` because of the here 
https://github.com/apache/pulsar/pull/8207/files/ac48262d4fa431de0364391cc585c9694fefd581..675b28d1755f8968ec51032f80543023d523465d#diff-bbd4739897f6a38e6b966ec9f8795ca5L686
 is not a thread-safe operation. 

##########
File path: 
pulsar-client/src/main/java/org/apache/pulsar/client/impl/ConsumerBase.java
##########
@@ -677,19 +677,16 @@ protected void notifyPendingBatchReceivedCallBack() {
         if (opBatchReceive == null || opBatchReceive.future == null) {
             return;
         }
-        notifyPendingBatchReceivedCallBack(opBatchReceive);
+        synchronized (incomingMessages) {

Review comment:
       Looks it's better to let the MessagesImpl.add() keep thread-safe. So 
that we can release the lock faster.




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