public synchronized static void addShutdownHook ( Runnable task ) { if ( task != null ) { Runtime . getRuntime ( ) . addShutdownHook ( new Thread ( ( ) -> { try { task . run ( ) ; } catch ( RuntimeException rex ) { Say . warn ( "Exception while processing shutdown-hook" , rex ) ; } } ) ) ; } }
Null - safe shortcut to Runtime method catching RuntimeExceptions .