Skip to content

Commit

Permalink
Separate blocking shutdown
Browse files Browse the repository at this point in the history
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 <ivan.hrasko@pantheon.tech>
  • Loading branch information
ihrasko committed Oct 31, 2024
1 parent b5da5b8 commit 473bb06
Showing 1 changed file with 14 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -189,11 +189,24 @@ public synchronized ListenableFuture<Boolean> 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());
Expand Down

0 comments on commit 473bb06

Please sign in to comment.