From a49061eb9ff9121e0009812290bb9fcc8370e7aa Mon Sep 17 00:00:00 2001 From: Marc Baloup Date: Thu, 17 Aug 2023 18:04:07 +0200 Subject: [PATCH] Removed the whole stop method synchronization block in CLIApplication. Not necessary due to the other one at the beginning of the method. --- .../fr/pandacube/lib/cli/CLIApplication.java | 30 ++++++++----------- 1 file changed, 13 insertions(+), 17 deletions(-) diff --git a/pandalib-cli/src/main/java/fr/pandacube/lib/cli/CLIApplication.java b/pandalib-cli/src/main/java/fr/pandacube/lib/cli/CLIApplication.java index 69f42d1..58f1fcd 100644 --- a/pandalib-cli/src/main/java/fr/pandacube/lib/cli/CLIApplication.java +++ b/pandalib-cli/src/main/java/fr/pandacube/lib/cli/CLIApplication.java @@ -61,28 +61,24 @@ public abstract class CLIApplication { } - private final Object stopLock = new Object(); private final AtomicBoolean stopping = new AtomicBoolean(false); @SuppressWarnings("finally") public final void stop() { - synchronized (stopLock) { - synchronized (stopping) { - if (stopping.get()) - return; - stopping.set(true); - } - Log.info("Stopping " + getName() + " version " + getClass().getPackage().getImplementationVersion()); - try { - end(); - } catch (Throwable t) { - Log.severe("Error stopping application " + getName() + " version " + getClass().getPackage().getImplementationVersion(), t); - } finally { - Log.info("Bye bye."); - System.exit(0); - } + synchronized (stopping) { + if (stopping.get()) + return; + stopping.set(true); + } + Log.info("Stopping " + getName() + " version " + getClass().getPackage().getImplementationVersion()); + try { + end(); + } catch (Throwable t) { + Log.severe("Error stopping application " + getName() + " version " + getClass().getPackage().getImplementationVersion(), t); + } finally { + Log.info("Bye bye."); + System.exit(0); } - } public boolean isStopping() {