RobertIndie commented on code in PR #14287:
URL: https://github.com/apache/pulsar/pull/14287#discussion_r1045609383


##########
pulsar-client/src/main/java/org/apache/pulsar/client/impl/ConsumerImpl.java:
##########
@@ -1026,8 +1028,9 @@ public CompletableFuture<Void> closeAsync() {
             closeConsumerTasks();
             deregisterFromClientCnx();
             client.cleanupConsumer(this);
-            failPendingReceive().whenComplete((r, t) -> 
closeFuture.complete(null));
-            return closeFuture;
+            failPendingReceive().whenComplete((r, t) -> 
closeConsumerFuture.complete(null));
+            closeFutures.addAll(closeDeadAndRetryProducer());

Review Comment:
   Is there a case that the consumer is disconnected but the DLQ and retry 
producer are not closed?



##########
pulsar-client/src/main/java/org/apache/pulsar/client/impl/ConsumerImpl.java:
##########
@@ -1049,12 +1052,34 @@ public CompletableFuture<Void> closeAsync() {
                 if (ignoreException && exception != null) {
                     log.debug("Exception ignored in closing consumer", 
exception);
                 }
-                cleanupAtClose(closeFuture, ignoreException ? null : 
exception);
+                cleanupAtClose(closeConsumerFuture, ignoreException ? null : 
exception);
                 return null;
             });
         }
+        closeFutures.add(closeConsumerFuture);
+        return CompletableFuture.allOf(closeFutures.toArray(new 
CompletableFuture[0]));
+    }
 
-        return closeFuture;
+    private List<CompletableFuture<Void>> closeDeadAndRetryProducer() {
+        final List<CompletableFuture<Void>> closeFutures = new ArrayList<>();
+        if (this.deadLetterProducer != null) {
+            try {
+                deadLetterProducer.whenComplete((r, t) -> {
+                    if (r != null) {
+                        closeFutures.add(r.closeAsync());

Review Comment:
   You should add `whenComplete` to closeFuturres. Otherwise, the 
deadLetterProducer may not be closed.



##########
pulsar-client/src/main/java/org/apache/pulsar/client/impl/ConsumerImpl.java:
##########
@@ -1049,12 +1052,34 @@ public CompletableFuture<Void> closeAsync() {
                 if (ignoreException && exception != null) {
                     log.debug("Exception ignored in closing consumer", 
exception);
                 }
-                cleanupAtClose(closeFuture, ignoreException ? null : 
exception);
+                cleanupAtClose(closeConsumerFuture, ignoreException ? null : 
exception);
                 return null;
             });
         }
+        closeFutures.add(closeConsumerFuture);
+        return CompletableFuture.allOf(closeFutures.toArray(new 
CompletableFuture[0]));

Review Comment:
   Please use `FutureUtil.waitForAll`



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