You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@pulsar.apache.org by GitBox <gi...@apache.org> on 2021/04/07 17:05:49 UTC

[GitHub] [pulsar] merlimat commented on a change in pull request #10159: [Client][Java] Close deadLetterProducer in Java consumer client (prevent potential leak)

merlimat commented on a change in pull request #10159:
URL: https://github.com/apache/pulsar/pull/10159#discussion_r608795618



##########
File path: pulsar-client/src/main/java/org/apache/pulsar/client/impl/ConsumerImpl.java
##########
@@ -938,6 +938,21 @@ private void closeConsumerTasks() {
         if (possibleSendToDeadLetterTopicMessages != null) {
             possibleSendToDeadLetterTopicMessages.clear();
         }
+
+        if (deadLetterProducer != null) {
+            try {
+                createProducerLock.writeLock().lock();

Review comment:
       This should typically go before the `try {`

##########
File path: pulsar-client/src/main/java/org/apache/pulsar/client/impl/ConsumerImpl.java
##########
@@ -938,6 +938,21 @@ private void closeConsumerTasks() {
         if (possibleSendToDeadLetterTopicMessages != null) {
             possibleSendToDeadLetterTopicMessages.clear();
         }
+
+        if (deadLetterProducer != null) {
+            try {
+                createProducerLock.writeLock().lock();
+                if (deadLetterProducer != null) {
+                    deadLetterProducer.thenApplyAsync(Producer::closeAsync);

Review comment:
       This would be done asynchronously. I think we should instead be waiting until the producer is close.




-- 
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:
users@infra.apache.org