public CompletableFuture shutdown()

in src/main/java/software/amazon/cloudwatchlogs/emf/sinks/AgentSink.java [93:110]


    public CompletableFuture<Void> shutdown() {
        executor.shutdown();
        return CompletableFuture.supplyAsync(
                () -> {
                    try {
                        while ((!executor.awaitTermination(1000, TimeUnit.MILLISECONDS))) {
                            // we add 1 because we assume that at least one task is running if the
                            // queue is blocked
                            log.debug(
                                    "Waiting for graceful shutdown to complete. {} tasks pending.",
                                    queue.size() + 1);
                        }
                    } catch (InterruptedException e) {
                        log.warn("Thread terminated while awaiting shutdown.");
                    }
                    return null;
                });
    }