@Override public void uncaughtException(Thread t, Throwable e) { try { // cannot use FormattingLogger due to a dependency loop logger.log( SEVERE, String.format(Locale.ROOT, "Caught an exception in %s. Shutting down.", t), e); } catch (Throwable errorInLogging) { // If logging fails, e.g. due to missing memory, at least try to log the // message and the cause for the failed logging. System.err.println(e.getMessage()); System.err.println(errorInLogging.getMessage()); } finally { runtime.exit(1); } } }
public static void exitProcess(int val, String msg) { String combinedErrorMessage = "Halting process: " + msg; LOG.error(combinedErrorMessage, new RuntimeException(combinedErrorMessage)); Runtime.getRuntime().exit(val); }
/** * Causes the VM to stop running and the program to exit with the given exit status. * If {@link #runFinalizersOnExit(boolean)} has been previously invoked with a * {@code true} argument, then all objects will be properly * garbage-collected and finalized first. */ public static void exit(int code) { Runtime.getRuntime().exit(code); }
@Override public void uncaughtException(Thread t, Throwable e) { try { // cannot use FormattingLogger due to a dependency loop logger.log( SEVERE, String.format(Locale.ROOT, "Caught an exception in %s. Shutting down.", t), e); } catch (Throwable errorInLogging) { // If logging fails, e.g. due to missing memory, at least try to log the // message and the cause for the failed logging. System.err.println(e.getMessage()); System.err.println(errorInLogging.getMessage()); } finally { runtime.exit(1); } } }
@Override public void syntaxError(Recognizer<?, ?> recognizer, Object offendingSymbol, int line, int charPositionInLine, String msg, RecognitionException e) { if (filePath == null) { return; } String errorMsg = "invalid toml syntax at " + filePath + ":" + line; errStream.println("error: " + errorMsg); Runtime.getRuntime().exit(1); }
@Override public void onFailure(Throwable cause) { System.out.println("Encountered error on writing data"); cause.printStackTrace(System.err); Runtime.getRuntime().exit(0); }
@Override public void onFailure(Throwable cause) { System.out.println("Encountered error on writing data"); cause.printStackTrace(System.err); Runtime.getRuntime().exit(0); }
@Override public void onFailure(Throwable cause) { System.out.println("Encountered error on writing data"); cause.printStackTrace(System.err); Runtime.getRuntime().exit(0); }
@Override public void onFailure(Throwable cause) { System.out.println("Encountered error on writing data"); cause.printStackTrace(System.err); Runtime.getRuntime().exit(0); }
@Override public void onFailure(Throwable cause) { System.out.println("Encountered error on writing data"); cause.printStackTrace(System.err); Runtime.getRuntime().exit(0); }
@Override public void onFailure(Throwable cause) { System.out.println("Encountered error on writing data"); cause.printStackTrace(System.err); Runtime.getRuntime().exit(0); }
public void uncaughtException(Thread thread, Throwable thrown) { try { handleUncaughtException(thrown); } catch (Error err) { LOG.error("Received error in main thread.. terminating server...", err); Runtime.getRuntime().exit(-2); } } });
@Override public void uncaughtException(Thread t, Throwable e) { try { // cannot use FormattingLogger due to a dependency loop logger.log( SEVERE, String.format(Locale.ROOT, "Caught an exception in %s. Shutting down.", t), e); } catch (Throwable errorInLogging) { // If logging fails, e.g. due to missing memory, at least try to log the // message and the cause for the failed logging. System.err.println(e.getMessage()); System.err.println(errorInLogging.getMessage()); } finally { runtime.exit(1); } } }
protected static void printUsageAndExit() { StringBuilder sb = new StringBuilder(); sb.append("Usage: OfflineMetaRepair [opts]\n"). append(" where [opts] are:\n"). append(" -details Display full report of all regions.\n"). append(" -base <hdfs://> Base Hbase Data directory.\n"). append(" -sidelineDir <hdfs://> HDFS path to backup existing meta and root.\n"). append(" -fix Auto fix as many problems as possible.\n"). append(" -fixHoles Auto fix as region holes."); System.err.println(sb.toString()); Runtime.getRuntime().exit(-2); }
@Override public void uncaughtException(Thread a, Throwable e) { try { Utils.handleUncaughtException(e); } catch (Error error) { LOG.info("Received error in main thread.. terminating server...", error); Runtime.getRuntime().exit(-2); } } }
@Override public void uncaughtException(Thread t, Throwable e) { try { LOG.error("Uncaught exception in netty " + e.getCause()); } catch (Throwable err) { // Doing nothing (probably due to an oom issue) and hoping Utils.handleUncaughtException will handle it } try { Utils.handleUncaughtException(e); } catch (Throwable throwable) { LOG.error("Exception thrown while handling uncaught exception " + throwable.getCause()); } LOG.info("Received error in netty thread.. terminating server..."); Runtime.getRuntime().exit(1); } }
@Override public void onFailure(Throwable cause) { recordSetWriter.abortTransmit(cause); System.out.println("Encountered error on writing data"); cause.printStackTrace(System.err); Runtime.getRuntime().exit(0); }
@Override public void exceptionCaught(ChannelHandlerContext ctx, Throwable cause) { try { LOG.error("server errors in handling the request", cause); } catch (Throwable err) { // Doing nothing (probably due to an oom issue) and hoping Utils.handleUncaughtException will handle it } try { Utils.handleUncaughtException(cause, ALLOWED_EXCEPTIONS); ctx.close(); } catch (Error error) { LOG.info("Received error in netty thread.. terminating server..."); Runtime.getRuntime().exit(1); } } }
private void sleepUntilSufficientTimeElapsed() { long now = System.currentTimeMillis(); if (now - getLastLogin() < MIN_TIME_BEFORE_RELOGIN) { LOG.warn("Not attempting to re-login since the last re-login was " + "attempted less than " + (MIN_TIME_BEFORE_RELOGIN / 1000) + " seconds" + " before."); try { Thread.sleep(MIN_TIME_BEFORE_RELOGIN - (now - getLastLogin())); } catch (InterruptedException e) { LOG.warn("TGT renewal thread has been interrupted and will exit."); Runtime.getRuntime().exit(-2); } } // register most recent relogin attempt setLastLogin(System.currentTimeMillis()); }
public void testExiter() { new Exiter(runtimeMock).uncaughtException(new Thread(), new Exception()); verify(runtimeMock).exit(1); } }