Codota Logo
Thread$UncaughtExceptionHandler
Code IndexAdd Codota to your IDE (free)

How to use
Thread$UncaughtExceptionHandler
in
java.lang

Best Java code snippets using java.lang.Thread$UncaughtExceptionHandler (Showing top 20 results out of 2,295)

  • Common ways to obtain Thread$UncaughtExceptionHandler
private void myMethod () {
Thread$UncaughtExceptionHandler t =
  • Codota IconThread.getDefaultUncaughtExceptionHandler()
  • Codota Iconnew Exiter(Runtime.getRuntime())
  • Codota IconString className;(UncaughtExceptionHandler) ClassLoader.getSystemClassLoader().loadClass(className).newInstance()
  • Smart code suggestions by Codota
}
origin: ReactiveX/RxJava

  @Override
  public void accept(Throwable error) throws Exception {
    Thread.currentThread().getUncaughtExceptionHandler().uncaughtException(Thread.currentThread(), error);
  }
});
origin: lealone/Lealone

/**
 * Send @param t to the default uncaught exception handler, or log it if none such is set up
 */
public static void handleOrLog(Throwable t) {
  if (Thread.getDefaultUncaughtExceptionHandler() == null)
    logger.error("Error in ThreadPoolExecutor", t);
  else
    Thread.getDefaultUncaughtExceptionHandler().uncaughtException(Thread.currentThread(), t);
}
origin: Rukey7/MvpApp

@Override
public void uncaughtException(Thread thread, Throwable ex) {
  TinkerLog.e(TAG, "uncaughtException:" + ex.getMessage());
  tinkerFastCrashProtect();
  tinkerPreVerifiedCrashHandler(ex);
  ueh.uncaughtException(thread, ex);
}
origin: twitter/distributedlog

/**
 * The executor re-throws exceptions thrown by the task to the uncaught exception handler
 * so we only need to do anything if uncaught exception handler has not been se
 */
private void logAndHandle(Throwable t, boolean passToHandler) {
  if (Thread.getDefaultUncaughtExceptionHandler() == null) {
    LOG.error("Unhandled exception on thread {}", Thread.currentThread().getName(), t);
  }
  else {
    LOG.info("Unhandled exception on thread {}", Thread.currentThread().getName(), t);
    if (passToHandler) {
      Thread.getDefaultUncaughtExceptionHandler().uncaughtException(Thread.currentThread(), t);
    }
  }
}
origin: reactor/reactor-core

static void handleError(Throwable ex) {
  Thread thread = Thread.currentThread();
  Throwable t = unwrap(ex);
  Thread.UncaughtExceptionHandler x = thread.getUncaughtExceptionHandler();
  if (x != null) {
    x.uncaughtException(thread, t);
  }
  else {
    log.error("Scheduler worker failed with an uncaught exception", t);
  }
  if (onHandleErrorHook != null) {
    onHandleErrorHook.accept(thread, t);
  }
}
origin: confluentinc/ksql

private void givenUncaughtException(final KsqlException e) {
 ehCapture.getValue().uncaughtException(new Thread(), e);
}
origin: ACRA/acra

/**
 * pass-through to default handler
 *
 * @param t the crashed thread
 * @param e the uncaught exception
 */
public void handReportToDefaultExceptionHandler(@Nullable Thread t, @NonNull Throwable e) {
  if (defaultExceptionHandler != null) {
    ACRA.log.i(LOG_TAG, "ACRA is disabled for " + context.getPackageName()
        + " - forwarding uncaught Exception on to default ExceptionHandler");
    defaultExceptionHandler.uncaughtException(t, e);
  } else {
    ACRA.log.e(LOG_TAG, "ACRA is disabled for " + context.getPackageName() + " - no default ExceptionHandler");
    ACRA.log.e(LOG_TAG, "ACRA caught a " + e.getClass().getSimpleName() + " for " + context.getPackageName(), e);
  }
}
origin: lealone/Lealone

/**
 * Close the file and the storage, without writing anything.
 * This method ignores all errors.
 */
private void closeImmediately() {
  try {
    closeStorage();
  } catch (Exception e) {
    if (backgroundExceptionHandler != null) {
      backgroundExceptionHandler.uncaughtException(null, e);
    }
  }
}
origin: fusesource/mqtt-client

  public void onFailure(Throwable value) {
    Thread.currentThread().getUncaughtExceptionHandler().uncaughtException(Thread.currentThread(), value);
  }
};
origin: org.springframework.boot/spring-boot

@Override
public void uncaughtException(Thread thread, Throwable ex) {
  try {
    if (isPassedToParent(ex) && this.parent != null) {
      this.parent.uncaughtException(thread, ex);
    }
  }
  finally {
    this.loggedExceptions.clear();
    if (this.exitCode != 0) {
      System.exit(this.exitCode);
    }
  }
}
origin: wildfly/wildfly

void safeRun(final Runnable task) {
  assert ! holdsLock(headLock) && ! holdsLock(tailLock);
  try {
    if (task != null) task.run();
  } catch (Throwable t) {
    try {
      exceptionHandler.uncaughtException(Thread.currentThread(), t);
    } catch (Throwable ignored) {
      // nothing else we can safely do here
    }
  } finally {
    // clear TCCL
    JBossExecutors.clearContextClassLoader(Thread.currentThread());
    // clear interrupt status
    Thread.interrupted();
  }
}
origin: lealone/Lealone

private IllegalStateException panic(IllegalStateException e) {
  if (backgroundExceptionHandler != null) {
    backgroundExceptionHandler.uncaughtException(null, e);
  }
  panicException = e;
  closeImmediately();
  return e;
}
origin: Tencent/tinker

@Override
public void uncaughtException(Thread thread, Throwable ex) {
  Log.e(TAG, "TinkerUncaughtHandler catch exception:" + Log.getStackTraceString(ex));
  ueh.uncaughtException(thread, ex);
origin: apache/incubator-gobblin

 @Test(expectedExceptions = RuntimeException.class)
 public void testUncaughtException() {
  Logger logger = Mockito.mock(Logger.class);

  Thread thread = new Thread();
  thread.setName("foo");
  RuntimeException runtimeException = new RuntimeException();
  String errorMessage = String.format("Thread %s threw an uncaught exception: %s", thread, runtimeException);
  Mockito.doThrow(runtimeException).when(logger).error(errorMessage, runtimeException);

  Thread.UncaughtExceptionHandler uncaughtExceptionHandler = new LoggingUncaughtExceptionHandler(Optional.of(logger));
  uncaughtExceptionHandler.uncaughtException(thread, runtimeException);
 }
}
origin: wildfly/wildfly

public void run() {
  Runnable task;
  for (;;) {
    synchronized (this) {
      task = poll();
      if (task == null) {
        runCount--;
        return;
      }
    }
    try {
      task.run();
    } catch (Throwable t) {
      final Thread.UncaughtExceptionHandler handler = LimitedExecutor.this.handler;
      if (handler != null) try {
        handler.uncaughtException(Thread.currentThread(), t);
      } catch (Throwable ignored) {}
    }
  }
}
origin: ACRA/acra

/**
 * End the application.
 */
private void endApplication(@Nullable Thread uncaughtExceptionThread, Throwable th) {
  final boolean letDefaultHandlerEndApplication = config.alsoReportToAndroidFramework();
  final boolean handlingUncaughtException = uncaughtExceptionThread != null;
  if (handlingUncaughtException && letDefaultHandlerEndApplication && defaultExceptionHandler != null) {
    // Let the system default handler do it's job and display the force close dialog.
    if (ACRA.DEV_LOGGING) ACRA.log.d(LOG_TAG, "Handing Exception on to default ExceptionHandler");
    defaultExceptionHandler.uncaughtException(uncaughtExceptionThread, th);
  } else {
    processFinisher.endApplication();
  }
}
origin: robovm/robovm

  private static void finalizerTimedOut(Object object) {
    // The current object has exceeded the finalization deadline; abort!
    String message = object.getClass().getName() + ".finalize() timed out after "
        + (MAX_FINALIZE_NANOS / NANOS_PER_SECOND) + " seconds";
    Exception syntheticException = new TimeoutException(message);
    // We use the stack from where finalize() was running to show where it was stuck.
    syntheticException.setStackTrace(FinalizerDaemon.INSTANCE.getStackTrace());
    Thread.UncaughtExceptionHandler h = Thread.getDefaultUncaughtExceptionHandler();
    if (h == null) {
      // If we have no handler, log and exit.
      System.logE(message, syntheticException);
      System.exit(2);
    }
    // Otherwise call the handler to do crash reporting.
    // We don't just throw because we're not the thread that
    // timed out; we're the thread that detected it.
    h.uncaughtException(Thread.currentThread(), syntheticException);
  }
}
origin: androidquery/androidquery

public static void report(Throwable e){
  
  if(e == null) return;
  try{
    //debug(e);
    warn("reporting", Log.getStackTraceString(e));
    
    if(eh != null){
      eh.uncaughtException(Thread.currentThread(), e);
    }
    
  }catch(Exception ex){
    ex.printStackTrace();
  }
  
}

origin: robovm/robovm

/**
 * Handles uncaught exceptions. Any uncaught exception in any {@code Thread}
 * is forwarded to the thread's {@code ThreadGroup} by invoking this
 * method.
 *
 * <p>New code should use {@link Thread#setUncaughtExceptionHandler} instead of thread groups.
 *
 * @param t the Thread that terminated with an uncaught exception
 * @param e the uncaught exception itself
 */
public void uncaughtException(Thread t, Throwable e) {
  if (parent != null) {
    parent.uncaughtException(t, e);
  } else if (Thread.getDefaultUncaughtExceptionHandler() != null) {
    // TODO The spec is unclear regarding this. What do we do?
    Thread.getDefaultUncaughtExceptionHandler().uncaughtException(t, e);
  } else if (!(e instanceof ThreadDeath)) {
    // No parent group, has to be 'system' Thread Group
    e.printStackTrace(System.err);
  }
}
origin: koral--/android-gif-drawable

@Override
public final void run() {
  try {
    if (!mGifDrawable.isRecycled()) {
      doWork();
    }
  } catch (Throwable throwable) {
    final Thread.UncaughtExceptionHandler uncaughtExceptionHandler = Thread.getDefaultUncaughtExceptionHandler();
    if (uncaughtExceptionHandler != null) {
      uncaughtExceptionHandler.uncaughtException(Thread.currentThread(), throwable);
    }
    throw throwable;
  }
}
java.langThread$UncaughtExceptionHandler

Javadoc

Interface for handlers invoked when a Thread abruptly terminates due to an uncaught exception.

When a thread is about to terminate due to an uncaught exception the Java Virtual Machine will query the thread for its UncaughtExceptionHandler using #getUncaughtExceptionHandler and will invoke the handler's uncaughtException method, passing the thread and the exception as arguments. If a thread has not had its UncaughtExceptionHandler explicitly set, then its ThreadGroup object acts as its UncaughtExceptionHandler. If the ThreadGroup object has no special requirements for dealing with the exception, it can forward the invocation to the #getDefaultUncaughtExceptionHandler.

Most used methods

  • uncaughtException
    Method invoked when the given thread terminates due to the given uncaught exception.Any exception th

Popular in Java

  • Running tasks concurrently on multiple threads
  • runOnUiThread (Activity)
  • putExtra (Intent)
  • notifyDataSetChanged (ArrayAdapter)
  • BigInteger (java.math)
    Immutable arbitrary-precision integers. All operations behave as if BigIntegers were represented in
  • SocketTimeoutException (java.net)
    This exception is thrown when a timeout expired on a socket read or accept operation.
  • ArrayList (java.util)
    Resizable-array implementation of the List interface. Implements all optional list operations, and p
  • Set (java.util)
    A collection that contains no duplicate elements. More formally, sets contain no pair of elements e1
  • TreeMap (java.util)
    A Red-Black tree based NavigableMap implementation. The map is sorted according to the Comparable of
  • Reflections (org.reflections)
    Reflections one-stop-shop objectReflections scans your classpath, indexes the metadata, allows you t
Codota Logo
  • Products

    Search for Java codeSearch for JavaScript codeEnterprise
  • IDE Plugins

    IntelliJ IDEAWebStormAndroid StudioEclipseVisual Studio CodePyCharmSublime TextPhpStormVimAtomGoLandRubyMineEmacsJupyter
  • Company

    About UsContact UsCareers
  • Resources

    FAQBlogCodota Academy Plugin user guide Terms of usePrivacy policyJava Code IndexJavascript Code Index
Get Codota for your IDE now