lhotari commented on a change in pull request #14538:
URL: https://github.com/apache/pulsar/pull/14538#discussion_r817630255
##########
File path:
pulsar-client/src/main/java/org/apache/pulsar/client/impl/PulsarClientImpl.java
##########
@@ -710,14 +713,30 @@ public void close() throws PulsarClientException {
final CompletableFuture<Void> closeFuture = new CompletableFuture<>();
List<CompletableFuture<Void>> futures = new ArrayList<>();
- producers.forEach(p -> futures.add(p.closeAsync()));
- consumers.forEach(c -> futures.add(c.closeAsync()));
+ producers.forEach(p -> futures.add(p.closeAsync().handle((__, t) -> {
+ log.error("Error closing producer {}", p, t);
+ return null;
+ })));
+ consumers.forEach(c -> futures.add(c.closeAsync().handle((__, t) -> {
+ log.error("Error closing consumer {}", c, t);
+ return null;
+ })));
// Need to run the shutdown sequence in a separate thread to prevent
deadlocks
// If there are consumers or producers that need to be shutdown we
cannot use the same thread
// to shutdown the EventLoopGroup as well as that would be trying to
shutdown itself thus a deadlock
// would happen
- FutureUtil.waitForAll(futures).thenRun(() -> new Thread(() -> {
+ CompletableFuture<Void> combinedFuture =
FutureUtil.waitForAll(futures);
+ ScheduledExecutorService shutdownExecutor =
Executors.newSingleThreadScheduledExecutor(
+ new
DefaultThreadFactory("pulsar-client-shutdown-timeout-scheduler"));
+ FutureUtil.addTimeoutHandling(combinedFuture,
Duration.ofSeconds(CLOSE_TIMEOUT_SECONDS),
+ shutdownExecutor, () ->
FutureUtil.createTimeoutException("Closing producers and consumers timed out.",
+ PulsarClientImpl.class, "closeAsync"));
+ combinedFuture.whenComplete((__, t) -> new Thread(() -> {
Review comment:
it does have a name. this thread existed already before this PR.
--
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]