michaeljmarshall commented on a change in pull request #12259:
URL: https://github.com/apache/pulsar/pull/12259#discussion_r720343235



##########
File path: 
pulsar-client/src/main/java/org/apache/pulsar/client/impl/ProducerImpl.java
##########
@@ -912,16 +906,14 @@ protected WriteInEventLoopCallback 
newObject(Handle<WriteInEventLoopCallback> ha
     }
 
     private void clearPendingMessagesWhenClose() {
-        PulsarClientException ex = new 
PulsarClientException.AlreadyClosedException(
-                format("The producer %s of the topic %s was already closed 
when closing the producers",
-                        producerName, topic));
-        pendingMessages.forEach(msg -> {
-            
client.getMemoryLimitController().releaseMemory(msg.uncompressedSize);
-            msg.sendComplete(ex);
-            msg.cmd.release();
-            msg.recycle();
-        });
-        pendingMessages.clear();
+        setState(State.Closed);
+        synchronized (this) {

Review comment:
       It's not clear to me why the `setState` method was ever in a 
`synchronized` block. In looking at the git history, it has been that way since 
the initial import. Since `setSet` has its own concurrency control and since we 
call `setState` outside of `synchronized` blocks in many other parts of the 
`ProducerImpl`, I don't see why this update should be in the `synchronized` 
block. Let me know if you think I am missing something, @eolivelli.




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