BewareMyPower commented on code in PR #21496:
URL: https://github.com/apache/pulsar/pull/21496#discussion_r1378819294
##########
pulsar-broker/src/main/java/org/apache/pulsar/broker/PulsarService.java:
##########
@@ -639,20 +639,23 @@ private synchronized void resetMetricsServlet() {
}
private CompletableFuture<Void> addTimeoutHandling(CompletableFuture<Void>
future) {
- ScheduledExecutorService shutdownExecutor =
Executors.newSingleThreadScheduledExecutor(
- new
ExecutorProvider.ExtendedThreadFactory(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) -> {
- if (t != null && getConfiguration().getBrokerShutdownTimeoutMs() >
0) {
- LOG.info("Shutdown timed out after {} ms",
getConfiguration().getBrokerShutdownTimeoutMs());
- LOG.info(ThreadDumpUtil.buildThreadDiagnosticString());
- }
- // shutdown the shutdown executor
- shutdownExecutor.shutdownNow();
- return null;
- });
+ long brokerShutdownTimeoutMs =
getConfiguration().getBrokerShutdownTimeoutMs();
Review Comment:
Maybe a guard clause could reduce unnecessary code changes in case there is
any minor change in the if block.
```java
if (brokerShutdownTimeoutMs <= 0) {
return future;
}
```
--
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]