lhotari commented on a change in pull request #10199:
URL: https://github.com/apache/pulsar/pull/10199#discussion_r614565941



##########
File path: 
pulsar-broker/src/main/java/org/apache/pulsar/broker/PulsarService.java
##########
@@ -480,6 +487,20 @@ public void close() throws PulsarServerException {
         }
     }
 
+    private CompletableFuture<Void> addTimeoutHandling(CompletableFuture<Void> 
future) {
+        ScheduledExecutorService shutdownExecutor = 
Executors.newSingleThreadScheduledExecutor(
+                new DefaultThreadFactory(getClass().getSimpleName() + 
"-shutdown"));
+        FutureUtil.addTimeoutHandling(future,
+                Duration.ofMillis(Math.max(1L, 
getConfiguration().getBrokerShutdownTimeoutMs())),
+                shutdownExecutor, () -> 
FutureUtil.createTimeoutException("Timeout in close", getClass(), "close"));
+        future.handle((v, t) -> {
+            // shutdown the shutdown executor
+            shutdownExecutor.shutdown();

Review comment:
       ~~`shutdown` is called from the thread executing in the 
shutdownExecutor. Therefore calling `.shutdownDown` or `.await` aren't 
suitable. (It's not really needed either since there aren't any blocking 
methods that the shutdownExecutor calls.)~~




-- 
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:
[email protected]


Reply via email to