WalletAppKit: move shutdownHook into its own method

This commit is contained in:
Sean Gilligan 2022-07-27 16:49:42 -07:00 committed by Andreas Schildbach
parent 509694d9ad
commit 952751eee2

View File

@ -469,14 +469,18 @@ public class WalletAppKit extends AbstractIdleService {
}
private void installShutdownHook() {
if (autoStop) Runtime.getRuntime().addShutdownHook(new Thread(() -> {
try {
WalletAppKit.this.stopAsync();
WalletAppKit.this.awaitTerminated();
} catch (Exception e) {
throw new RuntimeException(e);
}
}));
if (autoStop) {
Runtime.getRuntime().addShutdownHook(new Thread(this::shutdownHook));
}
}
private void shutdownHook() {
try {
stopAsync();
awaitTerminated();
} catch (Exception e) {
throw new RuntimeException(e);
}
}
@Override