Source:
public void uncaughtException(Thread thread, Throwable exception) { LOG.log(Level.SEVERE, "Exception caught in thread: " + thread.getName() + " with thread id: " + thread.getId(), exception); if (exception instanceof Error || thread.getId() == mainThreadId) { LOG.severe("Would not recover from error. Metrics Manager halts immediately"); Runtime.getRuntime().halt(1); } String sinkId = thread.getName(); SinkExecutor oldSinkExecutor = sinkExecutors.remove(sinkId); if (oldSinkExecutor != null) { metricsManagerServer.removeSinkCommunicator(oldSinkExecutor.getCommunicator()); SysUtils.closeIgnoringExceptions(oldSinkExecutor); } Integer thisSinkRetryAttempts = 0; if (sinksRetryAttempts.containsKey(sinkId)) { thisSinkRetryAttempts = sinksRetryAttempts.remove(sinkId); } if (oldSinkExecutor != null && thisSinkRetryAttempts != 0) { LOG.info(String.format("Restarting IMetricsSink: %s with %d available retries", sinkId, thisSinkRetryAttempts)); SinkExecutor newSinkExecutor = initSinkExecutor(sinkId); sinkExecutors.put(sinkId, newSinkExecutor); if (thisSinkRetryAttempts > 0) { thisSinkRetryAttempts--; } sinksRetryAttempts.put(sinkId, thisSinkRetryAttempts); metricsManagerServer.addSinkCommunicator(newSinkExecutor.getCommunicator()); executors.execute(newSinkExecutor); } else if (oldSinkExecutor != null && thisSinkRetryAttempts == 0 && sinkExecutors.size() > 0) { LOG.severe("Could not recover from exceptions for IMetricsSink: " + sinkId); LOG.info(sinkId + " would close and keep running rest sinks: " + sinkExecutors.keySet()); } else { LOG.info("Could not recover from exceptions; Metrics Manager Exiting"); for (Handler handler : java.util.logging.Logger.getLogger("").getHandlers()) { handler.close(); } executors.shutdownNow(); Runtime.getRuntime().halt(1); } }

Target:
public void uncaughtException(Thread thread, Throwable exception) { if (exception instanceof Error) { LOG.log(Level.SEVERE, "Error caught in thread: " + thread.getName() + " with thread id: " + thread.getId() + ". Process halting...", exception); Runtime.getRuntime().halt(1); } if (thread.getId() == mainThreadId) { LOG.log(Level.SEVERE, "Exception caught in main thread. Process halting...", exception); Runtime.getRuntime().halt(1); } LOG.log(Level.SEVERE, "Exception caught in thread: " + thread.getName() + " with thread id: " + thread.getId(), exception); String sinkId = null; Integer thisSinkRetryAttempts = 0; if (sinkExecutors.containsKey(thread.getName())) { sinkId = thread.getName(); SinkExecutor oldSinkExecutor = sinkExecutors.remove(sinkId); metricsManagerServer.removeSinkCommunicator(oldSinkExecutor.getCommunicator()); SysUtils.closeIgnoringExceptions(oldSinkExecutor); thisSinkRetryAttempts = sinksRetryAttempts.remove(sinkId); } if (sinkId != null && thisSinkRetryAttempts != 0) { LOG.info(String.format("Restarting IMetricsSink: %s with %d available retries", sinkId, thisSinkRetryAttempts)); SinkExecutor newSinkExecutor = initSinkExecutor(sinkId); sinkExecutors.put(sinkId, newSinkExecutor); if (thisSinkRetryAttempts > 0) { thisSinkRetryAttempts--; } sinksRetryAttempts.put(sinkId, thisSinkRetryAttempts); metricsManagerServer.addSinkCommunicator(newSinkExecutor.getCommunicator()); executors.execute(newSinkExecutor); } else if (sinkId != null && thisSinkRetryAttempts == 0 && sinkExecutors.size() > 0) { LOG.severe("Failed to recover from exceptions for IMetricsSink: " + sinkId); LOG.info(sinkId + " would close and keep running rest sinks: " + sinkExecutors.keySet()); } else { LOG.info("Failed to recover from exceptions; Metrics Manager Exiting"); for (Handler handler : java.util.logging.Logger.getLogger("").getHandlers()) { handler.close(); } executors.shutdownNow(); Runtime.getRuntime().halt(1); } }