Skip to content

Commit

Permalink
Get rid of some added lambdas
Browse files Browse the repository at this point in the history
  • Loading branch information
gsmet committed Aug 1, 2024
1 parent 3491935 commit f703ebb
Showing 1 changed file with 17 additions and 10 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -50,13 +50,21 @@ public class ApplicationLifecycleManager {

// used by ShutdownEvent to propagate the information about shutdown reason
public static volatile ShutdownEvent.ShutdownReason shutdownReason = ShutdownEvent.ShutdownReason.STANDARD;
private static final BiConsumer<Integer, Throwable> MAIN_EXIT_CODE_HANDLER = (integer, cause) -> {
Logger logger = Logger.getLogger(Application.class);
logger.debugf("Shutting down with exit code %s", integer);
if (logger.isTraceEnabled()) {
logger.tracef(new RuntimeException("Shutdown Stack Trace"), "Shutdown triggered");
private static final BiConsumer<Integer, Throwable> MAIN_EXIT_CODE_HANDLER = new BiConsumer<>() {
@Override
public void accept(Integer integer, Throwable cause) {
Logger logger = Logger.getLogger(Application.class);
logger.debugf("Shutting down with exit code %s", integer);
if (logger.isTraceEnabled()) {
logger.tracef(new RuntimeException("Shutdown Stack Trace"), "Shutdown triggered");
}
System.exit(integer);
}
};
private static final Consumer<Boolean> NOOP_ALREADY_STARTED_CALLBACK = new Consumer<>() {
@Override
public void accept(Boolean t) {
}
System.exit(integer);
};
private static volatile BiConsumer<Integer, Throwable> defaultExitCodeHandler = MAIN_EXIT_CODE_HANDLER;

Expand All @@ -76,8 +84,7 @@ private ApplicationLifecycleManager() {
private static volatile boolean shutdownRequested;
private static volatile Application currentApplication;
private static boolean vmShuttingDown;
private static Consumer<Boolean> alreadyStartedCallback = b -> {
};
private static Consumer<Boolean> alreadyStartedCallback = NOOP_ALREADY_STARTED_CALLBACK;

private static final boolean IS_WINDOWS = System.getProperty("os.name").toLowerCase(Locale.ENGLISH).contains("windows");
private static final boolean IS_MAC = System.getProperty("os.name").toLowerCase(Locale.ENGLISH).contains("mac");
Expand Down Expand Up @@ -379,8 +386,8 @@ public static void setDefaultExitCodeHandler(Consumer<Integer> defaultExitCodeHa
@SuppressWarnings("unused")
// Used by StartupActionImpl via reflection
public static void setAlreadyStartedCallback(Consumer<Boolean> alreadyStartedCallback) {
ApplicationLifecycleManager.alreadyStartedCallback = alreadyStartedCallback != null ? alreadyStartedCallback : b -> {
};
ApplicationLifecycleManager.alreadyStartedCallback = alreadyStartedCallback != null ? alreadyStartedCallback
: NOOP_ALREADY_STARTED_CALLBACK;
}

/**
Expand Down

0 comments on commit f703ebb

Please sign in to comment.