From 7c84af37b0a4c1db5f3f336cfbdb698e561b44f8 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) --- .../controller/api/AbstractLightyModule.java | 18 +++++++++++++++++- 1 file changed, 17 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..0efe492cf 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 @@ -192,7 +192,6 @@ public synchronized ListenableFuture shutdown() { @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()); @@ -208,4 +207,21 @@ public final boolean shutdown(final long duration, final TimeUnit unit) { } return false; } + + /** + * 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); + } }