List of usage examples for java.lang Thread getUncaughtExceptionHandler
public UncaughtExceptionHandler getUncaughtExceptionHandler()
From source file:Main.java
public static void main(String[] args) { Thread t = new Thread(new Main()); t.setUncaughtExceptionHandler(new OverrideExceptionHandler()); System.out.println(t.getUncaughtExceptionHandler()); t.start();/*w w w . j a v a 2 s . c om*/ }
From source file:TestOverrideThread.java
public static void main(String[] args) { Thread t = new Thread(new TestOverrideThread()); t.setUncaughtExceptionHandler(new OverrideExceptionHandler()); System.out.println(t.getUncaughtExceptionHandler()); t.start();//from w w w . j a va2 s. com }
From source file:Main.java
public static void throwUncaughtException(Thread t, Throwable th) { Thread.UncaughtExceptionHandler ueh = t.getUncaughtExceptionHandler(); if (ueh != null) { ueh.uncaughtException(t, th);//w ww . j av a 2 s. c o m } }
From source file:edu.umn.msi.tropix.common.concurrent.impl.UncaughtExceptionHandlerUtils.java
public static void handleException(@Nullable final UncaughtExceptionHandler handler, final Throwable t) { final Thread currentThread = Thread.currentThread(); UncaughtExceptionHandler eh;//from w w w .j a v a 2 s. co m if (handler != null) { eh = handler; } else { eh = currentThread.getUncaughtExceptionHandler(); } try { eh.uncaughtException(currentThread, t); } catch (final Throwable exceptionThrowable) { ExceptionUtils.logQuietly(LOG, exceptionThrowable); } }
From source file:com.amazon.carbonado.repo.replicated.ReplicationTrigger.java
private void resyncFailed(ResyncCapability.Listener<? super S> listener, S replicaEntry, S masterEntry, S newReplicaEntry, Object state) { if (listener != null) { try {//from w w w . j a v a 2 s .c o m if (replicaEntry == null) { listener.failedInsert(newReplicaEntry, state); } else if (masterEntry != null) { listener.failedUpdate(newReplicaEntry, state); } else { listener.failedDelete(replicaEntry, state); } } catch (Throwable e2) { Thread t = Thread.currentThread(); t.getUncaughtExceptionHandler().uncaughtException(t, e2); } } }
From source file:org.dcache.xrootd.standalone.DataServerHandler.java
@Override public void exceptionCaught(ChannelHandlerContext ctx, Throwable t) { if (t instanceof ClosedChannelException) { _log.info("Connection closed"); } else if (t instanceof RuntimeException || t instanceof Error) { Thread me = Thread.currentThread(); me.getUncaughtExceptionHandler().uncaughtException(me, t); } else {/*w w w. j a v a 2 s . c o m*/ _log.warn(t.toString()); } // TODO: If not already closed, we should probably close the // channel. }
From source file:org.springframework.boot.devtools.restart.Restarter.java
/** * Internal constructor to create a new {@link Restarter} instance. * @param thread the source thread//from w ww . j a v a 2 s .co m * @param args the application arguments * @param forceReferenceCleanup if soft/weak reference cleanup should be forced * @param initializer the restart initializer * @see #initialize(String[]) */ protected Restarter(Thread thread, String[] args, boolean forceReferenceCleanup, RestartInitializer initializer) { Assert.notNull(thread, "Thread must not be null"); Assert.notNull(args, "Args must not be null"); Assert.notNull(initializer, "Initializer must not be null"); this.logger.debug("Creating new Restarter for thread " + thread); SilentExitExceptionHandler.setup(thread); this.forceReferenceCleanup = forceReferenceCleanup; this.initialUrls = initializer.getInitialUrls(thread); this.mainClassName = getMainClassName(thread); this.applicationClassLoader = thread.getContextClassLoader(); this.args = args; this.exceptionHandler = thread.getUncaughtExceptionHandler(); this.leakSafeThreads.add(new LeakSafeThread()); }