Tabnine Logo
Thread.getDefaultUncaughtExceptionHandler
Code IndexAdd Tabnine to your IDE (free)

How to use
getDefaultUncaughtExceptionHandler
method
in
java.lang.Thread

Best Java code snippets using java.lang.Thread.getDefaultUncaughtExceptionHandler (Showing top 20 results out of 1,458)

origin: aa112901/remusic

public UnceHandler(MainApplication application) {
  //获取系统默认的UncaughtException处理器
  mDefaultHandler = Thread.getDefaultUncaughtExceptionHandler();
  this.application = application;
}
origin: stackoverflow.com

 if(!(Thread.getDefaultUncaughtExceptionHandler() instanceof CustomExceptionHandler)) {
  Thread.setDefaultUncaughtExceptionHandler(new CustomExceptionHandler(
      "/sdcard/<desired_local_path>", "http://<desired_url>/upload.php"));
}
origin: smuyyh/BookReader

/**
 * 初始化
 *
 * @param context
 */
public void init(Context context) {
  mContext = context;
  //获取系统默认的UncaughtException处理器
  mDefaultHandler = Thread.getDefaultUncaughtExceptionHandler();
  //设置该CrashHandler为程序的默认处理器
  Thread.setDefaultUncaughtExceptionHandler(this);
}
origin: iSoron/uhabits

public BaseExceptionHandler(@NonNull BaseActivity activity)
{
  this.activity = activity;
  originalHandler = Thread.getDefaultUncaughtExceptionHandler();
}
origin: apache/hive

 @Override
 public void onFailure(Throwable t) {
  LOG.error("Wait queue scheduler worker exited with failure!", t);
  Thread.getDefaultUncaughtExceptionHandler().uncaughtException(Thread.currentThread(), t);
 }
}
origin: Rukey7/MvpApp

public void init(Context context) {
  mDefaultCrashHandler = Thread.getDefaultUncaughtExceptionHandler();
  Thread.setDefaultUncaughtExceptionHandler(this);
  mContext = context.getApplicationContext();
}
origin: Tencent/tinker

public TinkerUncaughtHandler(Context context) {
  this.context = context;
  ueh = Thread.getDefaultUncaughtExceptionHandler();
  crashFile = SharePatchFileUtil.getPatchLastCrashFile(context);
}
origin: square/okhttp

@Override public void testRunStarted(Description description) {
 System.err.println("Installing aggressive uncaught exception handler");
 oldDefaultUncaughtExceptionHandler = Thread.getDefaultUncaughtExceptionHandler();
 Thread.setDefaultUncaughtExceptionHandler((thread, throwable) -> {
  StringWriter errorText = new StringWriter(256);
  errorText.append("Uncaught exception in OkHttp thread \"");
  errorText.append(thread.getName());
  errorText.append("\"\n");
  throwable.printStackTrace(new PrintWriter(errorText));
  errorText.append("\n");
  if (lastTestStarted != null) {
   errorText.append("Last test to start was: ");
   errorText.append(lastTestStarted.getDisplayName());
   errorText.append("\n");
  }
  System.err.print(errorText.toString());
  synchronized (exceptions) {
   exceptions.put(throwable, lastTestStarted.getDisplayName());
  }
 });
}
origin: apache/hive

 @Override
 public void onFailure(Throwable t) {
  if (t instanceof CancellationException && isShutdown.get()) {
   LOG.info("AMReporter QueueDrainer exited as a result of a cancellation after shutdown");
  } else {
   LOG.error("AMReporter QueueDrainer exited with error", t);
   Thread.getDefaultUncaughtExceptionHandler().uncaughtException(Thread.currentThread(), t);
  }
 }
});
origin: oracle/opengrok

  public static void registerErrorHandler() {
    UncaughtExceptionHandler dueh =
      Thread.getDefaultUncaughtExceptionHandler();
    if (dueh == null) {
      LOGGER.log(Level.FINE, "Installing default uncaught exception handler");
      Thread.setDefaultUncaughtExceptionHandler(new UncaughtExceptionHandler() {
        @Override
        public void uncaughtException(Thread t, Throwable e) {
          LOGGER.log(Level.SEVERE, "Uncaught exception in thread "
            + t.getName() + " with ID " + t.getId() + ": "
            + e.getMessage(), e);
        }
      });
    }
  }
}
origin: apache/hive

private void insertIntoPreemptionQueueOrFailUnlocked(TaskWrapper taskWrapper) {
 boolean added = preemptionQueue.offer(taskWrapper);
 if (!added) {
  LOG.warn("Failed to add element {} to preemption queue. Terminating", taskWrapper);
  Thread.getDefaultUncaughtExceptionHandler().uncaughtException(Thread.currentThread(),
    new IllegalStateException("Preemption queue full. Cannot proceed"));
 }
}
origin: apache/hive

@Override
public void onSuccess(Object result) {
 if (isShutdown.get()) {
  LOG.info("Wait queue scheduler worker exited with success!");
 } else {
  LOG.error("Wait queue scheduler worker exited with success!");
  Thread.getDefaultUncaughtExceptionHandler().uncaughtException(Thread.currentThread(),
    new IllegalStateException("WaitQueue worked exited before shutdown"));
 }
}
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: 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: ankidroid/Anki-Android

/**
 * We want to send an analytics hit on any exception, then chain to other handlers (e.g., ACRA)
 */
synchronized private static void installDefaultExceptionHandler() {
  sOriginalUncaughtExceptionHandler = Thread.getDefaultUncaughtExceptionHandler();
  Thread.setDefaultUncaughtExceptionHandler((thread, throwable) -> {
    sendAnalyticsException(throwable, true);
    sOriginalUncaughtExceptionHandler.uncaughtException(thread, throwable);
  });
}
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;
  }
}
origin: spotify/helios

@Before
public void setup() throws Exception {
 zk = new ZooKeeperTestingServerManager();
 dueh = Thread.getDefaultUncaughtExceptionHandler();
 Thread.setDefaultUncaughtExceptionHandler(new Thread.UncaughtExceptionHandler() {
  @Override
  public void uncaughtException(final Thread thread, final Throwable th) {}
 });
 stateDir = Files.createTempDirectory("helios-agent-conflict-test");
 first = makeAgent("first");
 second = makeAgent("second");
}
origin: ReactiveX/RxJava

Thread.UncaughtExceptionHandler originalHandler = Thread.getDefaultUncaughtExceptionHandler();
try {
  CapturingUncaughtExceptionHandler handler = new CapturingUncaughtExceptionHandler();
origin: ReactiveX/RxJava

private static void expectUncaughtTestException(Action action) {
  Thread.UncaughtExceptionHandler originalHandler = Thread.getDefaultUncaughtExceptionHandler();
  CapturingUncaughtExceptionHandler handler = new CapturingUncaughtExceptionHandler();
  Thread.setDefaultUncaughtExceptionHandler(handler);
  RxJavaPlugins.setErrorHandler(new Consumer<Throwable>() {
    @Override
    public void accept(Throwable error) throws Exception {
      Thread.currentThread().getUncaughtExceptionHandler().uncaughtException(Thread.currentThread(), error);
    }
  });
  try {
    action.run();
    assertEquals("Should have received exactly 1 exception", 1, handler.count);
    Throwable caught = handler.caught;
    while (caught != null) {
      if (caught instanceof TestException) { break; }
      if (caught == caught.getCause()) { break; }
      caught = caught.getCause();
    }
    assertTrue("A TestException should have been delivered to the handler",
        caught instanceof TestException);
  } catch (Throwable ex) {
    throw ExceptionHelper.wrapOrThrow(ex);
  } finally {
    Thread.setDefaultUncaughtExceptionHandler(originalHandler);
    RxJavaPlugins.setErrorHandler(null);
  }
}
origin: ReactiveX/RxJava

Thread.UncaughtExceptionHandler originalHandler = Thread.getDefaultUncaughtExceptionHandler();
try {
  CapturingUncaughtExceptionHandler handler = new CapturingUncaughtExceptionHandler();
java.langThreadgetDefaultUncaughtExceptionHandler

Javadoc

Returns the default handler invoked when a thread abruptly terminates due to an uncaught exception. If the returned value is null, there is no default.

Popular methods of Thread

  • currentThread
  • sleep
    Causes the currently executing thread to sleep (temporarily cease execution) for the specified numbe
  • <init>
    Constructs a new Thread with no Runnable object, the given name and belonging to the ThreadGroup pas
  • start
    Causes this thread to begin execution; the Java Virtual Machine calls the run method of this thread
  • getContextClassLoader
    Returns the context ClassLoader for this Thread. The context ClassLoader is provided by the creator
  • interrupt
    Interrupts this thread. Unless the current thread is interrupting itself, which is always permitted,
  • setDaemon
    Marks this thread as either a #isDaemon thread or a user thread. The Java Virtual Machine exits when
  • getName
    Returns this thread's name.
  • join
    Waits at most millis milliseconds plus nanos nanoseconds for this thread to die. This implementatio
  • setContextClassLoader
    Sets the context ClassLoader for this Thread. The context ClassLoader can be set when a thread is cr
  • setName
    Changes the name of this thread to be equal to the argumentname. First the checkAccess method of thi
  • interrupted
    Tests whether the current thread has been interrupted. Theinterrupted status of the thread is cleare
  • setName,
  • interrupted,
  • getStackTrace,
  • getId,
  • isInterrupted,
  • isAlive,
  • setPriority,
  • yield,
  • getThreadGroup,
  • getPriority

Popular in Java

  • Updating database using SQL prepared statement
  • compareTo (BigDecimal)
  • getOriginalFilename (MultipartFile)
    Return the original filename in the client's filesystem.This may contain path information depending
  • putExtra (Intent)
  • Graphics2D (java.awt)
    This Graphics2D class extends the Graphics class to provide more sophisticated control overgraphics
  • Rectangle (java.awt)
    A Rectangle specifies an area in a coordinate space that is enclosed by the Rectangle object's top-
  • PrintStream (java.io)
    Fake signature of an existing Java class.
  • TreeSet (java.util)
    TreeSet is an implementation of SortedSet. All optional operations (adding and removing) are support
  • Filter (javax.servlet)
    A filter is an object that performs filtering tasks on either the request to a resource (a servlet o
  • LogFactory (org.apache.commons.logging)
    Factory for creating Log instances, with discovery and configuration features similar to that employ
  • Top 12 Jupyter Notebook extensions
Tabnine Logo
  • Products

    Search for Java codeSearch for JavaScript code
  • IDE Plugins

    IntelliJ IDEAWebStormVisual StudioAndroid StudioEclipseVisual Studio CodePyCharmSublime TextPhpStormVimGoLandRubyMineEmacsJupyter NotebookJupyter LabRiderDataGripAppCode
  • Company

    About UsContact UsCareers
  • Resources

    FAQBlogTabnine AcademyTerms of usePrivacy policyJava Code IndexJavascript Code Index
Get Tabnine for your IDE now