eolivelli commented on a change in pull request #12259:
URL: https://github.com/apache/pulsar/pull/12259#discussion_r719979012
##########
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:
in the previous code "setState" was inside the `synchronized` block
so probably is is better to keep it inside that block.
At that point we can simply move the `synchronized` keyword in the
signature of the method
##########
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() {
Review comment:
what about changing this name to "closeAndClearPendingMessages" ?
because now the method does something different from the previous behaviour
--
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]