Class SafeShutdown


  • public final class SafeShutdown
    extends java.lang.Object
    This class should be used to shutdown GRIP safely. This is because shutdown hooks may throw exceptions, as such we need to know if the application being is shutdown.
    • Field Detail

      • stopping

        public static volatile boolean stopping
    • Method Detail

      • exit

        public static void exit​(SafeShutdown.ExitCode statusCode,
                                @Nullable
                                SafeShutdown.PreSystemExitHook hook)
        Shutdown's the VM in such a way that flags that the vm is stopping. This is so that we don't run the normal exception handling code when shutting down the application.
        Parameters:
        statusCode - exit status.
        hook - The hook to run before the System shutdown. This will be run after stopping has been flagged true. This is nullable.
        See Also:
        System.exit(int)
      • isStopping

        public static boolean isStopping()
        HACK! Shutdown hooks can throw exceptions. On Windows, the static method after Loader.loadLibrary(java.net.URL[], java.lang.String, java.lang.String...) throws such an exception in a shutdown hook.
        Returns:
        True if if the application is shutting down.
        See Also:
        GRIP Issue, Bytedeco issue
      • flagStopping

        public static void flagStopping()
        Flags that the application is shutting down.