MCPcopy Create free account
hub / github.com/PCGen/pcgen / exit

Method exit

code/src/java/pcgen/util/GracefulExit.java:41–73  ·  view source on GitHub ↗

Exits the JVM with the given status code. This method will call all registered interceptors before exiting. If any interceptor returns false, the exit will be canceled. @param status The status code to exit with

(int status)

Source from the content-addressed store, hash-verified

39 * @param status The status code to exit with
40 */
41 public static void exit(int status)
42 {
43 try
44 {
45 lock.lock();
46 LOG.log(Level.FINEST, () -> MessageFormat.format(
47 "Started exiting with the status {0}. There are {1} interceptors.", status,
48 interceptors.size()));
49 isShuttingDown = true;
50
51 boolean shouldExit = interceptors.stream()
52 .map((ExitInterceptor interceptor) -> {
53 boolean intercepted = interceptor.intercept(status);
54 LOG.log(Level.FINEST,
55 MessageFormat.format("Intercepted exit: {0} from registered interceptor: {1}",
56 intercepted, interceptor.getClass().getName()));
57 return intercepted;
58 })
59 .filter(Predicate.isEqual(Boolean.FALSE))
60 .findAny()
61 .orElse(Boolean.TRUE);
62
63 if (shouldExit)
64 {
65 LOG.info(() -> MessageFormat.format("Exiting gracefully with status {0}", status));
66 exitFunction.exit(status);
67 }
68 } finally
69 {
70 isShuttingDown = false;
71 lock.unlock();
72 }
73 }
74
75 /**
76 * Adds an interceptor to the list of interceptors. This method can be called before or after shutdown has started,

Callers 14

ConvertPanelMethod · 0.95
checkExitMethod · 0.95
CommandLineArgumentsMethod · 0.95
mainMethod · 0.95
validateEnvironmentMethod · 0.95
loadPropertiesMethod · 0.95
shutdownMethod · 0.95
testDefaultExitMethod · 0.95
testAddHookDuringExitMethod · 0.95
testAddExitDuringExitMethod · 0.95

Calls 8

formatMethod · 0.80
streamMethod · 0.80
interceptMethod · 0.80
sizeMethod · 0.65
orElseMethod · 0.65
getNameMethod · 0.65
exitMethod · 0.65
logMethod · 0.45

Tested by 7

testDefaultExitMethod · 0.76
testAddHookDuringExitMethod · 0.76
testAddExitDuringExitMethod · 0.76
testExitHookSequenceMethod · 0.76