Ejemplo n.º 1
0
 @Override
 public void uncaughtException(Thread t, Throwable e) {
   LOG.info("UncaughtExceptionHandler invoked");
   if (ShutdownHookManager.isShutdownInProgress()) {
     LOG.warn("Thread {} threw a Throwable, but we are shutting down, so ignoring this", t, e);
   } else if (e instanceof Error) {
     try {
       LOG.error("Thread {} threw an Error.  Shutting down now...", t, e);
     } catch (Throwable err) {
       // We don't want to not exit because of an issue with logging
     }
     if (e instanceof OutOfMemoryError) {
       // After catching an OOM java says it is undefined behavior, so don't
       // even try to clean up or we can get stuck on shutdown.
       try {
         System.err.println("Halting due to Out Of Memory Error...");
         e.printStackTrace();
       } catch (Throwable err) {
         // Again we done want to exit because of logging issues.
       }
       ExitUtil.halt(-1);
     } else {
       ExitUtil.terminate(-1);
     }
   } else {
     LOG.error("Thread {} threw an Exception. Shutting down now...", t, e);
     ExitUtil.terminate(-1);
   }
 }
Ejemplo n.º 2
0
 /**
  * Forcibly terminates the currently running Java virtual machine.
  *
  * @param status
  * @throws ExitException
  */
 public static void halt(int status) throws HaltException {
   halt(status, "HaltException");
 }
Ejemplo n.º 3
0
 /**
  * Forcibly terminates the currently running Java virtual machine.
  *
  * @param status
  * @param t
  * @throws ExitException
  */
 public static void halt(int status, Throwable t) throws HaltException {
   halt(status, StringUtils.stringifyException(t));
 }