Technoboy- commented on code in PR #15680:
URL: https://github.com/apache/pulsar/pull/15680#discussion_r879156654


##########
pulsar-broker/src/main/java/org/apache/pulsar/broker/PulsarService.java:
##########
@@ -578,21 +582,34 @@ public CompletableFuture<Void> closeAsync() {
         }
     }
 
+    private void close(AutoCloseable closeable, String resource, 
ScheduledExecutorService shutdownExecutor) {
+        final CompletableFuture<Void> future = new CompletableFuture<>();
+        shutdownExecutor.execute(() -> {
+            try {
+                closeable.close();
+                future.complete(null);
+            } catch (Exception e) {
+                LOG.warn("Failed to close {}", resource, e);
+                future.completeExceptionally(new IllegalStateException("Failed 
to close " + resource));
+            }
+        });
+        CompletableFuture<Void> result = FutureUtil.addTimeoutHandling(future,
+                Duration.ofMillis(Math.max(1L, 
config.getBrokerShutdownTimeoutMs())), shutdownExecutor,
+                () -> new TimeoutException("Timeout to close " + resource));
+        try {
+            result.join();

Review Comment:
   yes,



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