From 2b584f245447bc9fd19424a2201050b372c56857 Mon Sep 17 00:00:00 2001 From: Ivan Hrasko Date: Thu, 31 Oct 2024 09:32:55 +0100 Subject: [PATCH] Separate blocking shutdown Separate unlocking CountDownLatch to shutdownBlocking() to avoid interaction with CountDownLatch for users who do not call blocking start. JIRA: LIGHTY-299 Signed-off-by: Ivan Hrasko (cherry picked from commit 473bb063d18b3f0ba602ded335bff8fb045fed25) --- .../core/controller/api/AbstractLightyModule.java | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) diff --git a/lighty-core/lighty-controller/src/main/java/io/lighty/core/controller/api/AbstractLightyModule.java b/lighty-core/lighty-controller/src/main/java/io/lighty/core/controller/api/AbstractLightyModule.java index c456cc9e8..42a599f4f 100644 --- a/lighty-core/lighty-controller/src/main/java/io/lighty/core/controller/api/AbstractLightyModule.java +++ b/lighty-core/lighty-controller/src/main/java/io/lighty/core/controller/api/AbstractLightyModule.java @@ -188,11 +188,24 @@ public synchronized ListenableFuture shutdown() { return shutdownFuture; } + /** + * Invoke blocking shutdown after blocking start + * Release CountDownLatch locking this thread and shutdown. + * @param duration duration to wait for shutdown to complete + * @param unit {@link TimeUnit} of {@code duration} + * @return {@code boolean} indicating shutdown sucess + * @deprecated Use {@code shutdown()} or {@code shutdown(duration, unit)} instead in case you want blocking shutdown. + */ + @Deprecated(forRemoval = true) + public final boolean shutdownBlocking(final long duration, final TimeUnit unit) { + shutdownLatch.countDown(); + return shutdown(duration, unit); + } + @SuppressWarnings("IllegalCatch") @Override public final boolean shutdown(final long duration, final TimeUnit unit) { try { - shutdownLatch.countDown(); final var stopSuccess = shutdown().get(duration, unit); if (stopSuccess) { LOG.info("LightyModule {} stopped successfully!", getClass().getSimpleName());