@Test public void testUnobservedError() throws InterruptedException { try { final Object sync = new Object(); Task.setUnobservedExceptionHandler(new Task.UnobservedExceptionHandler() { @Override public void unobservedException(Task<?> t, UnobservedTaskException e) { synchronized (sync) { sync.notify(); } } }); synchronized (sync) { startFailedTask(); System.gc(); sync.wait(); } } finally { Task.setUnobservedExceptionHandler(null); } }
public static void setUnobservedExceptionHandler(UnobservedExceptionHandler eh) { unobservedExceptionHandler = eh; }
Task { public static void setUnobservedExceptionHandler(UnobservedExceptionHandler eh) { unobservedExceptionHandler = eh; } }
Task { public static void setUnobservedExceptionHandler(UnobservedExceptionHandler eh) { unobservedExceptionHandler = eh; } Task(); private  Task(TResult result); private  Task(boolean cancelled); }
Task { public static void setUnobservedExceptionHandler(UnobservedExceptionHandler eh) { unobservedExceptionHandler = eh; } Task(); private  Task(TResult result); private  Task(boolean cancelled); static UnobservedExceptionHandler getUnobservedExceptionHandler(); static void setUnobservedExceptionHandler(UnobservedExceptionHandler eh); static Task<TResult>.TaskCompletionSource create(); boolean isCompleted(); boolean isCancelled(); boolean isFaulted(); TResult getResult(); Exception getError(); void waitForCompletion(); boolean waitForCompletion(long duration, TimeUnit timeUnit); @SuppressWarnings("unchecked") static Task<TResult> forResult(TResult value); static Task<TResult> forError(Exception error); @SuppressWarnings("unchecked") static Task<TResult> cancelled(); static Task<Void> delay(long delay); static Task<Void> delay(long delay, CancellationToken cancellationToken); Task<TOut> cast(); Task<Void> makeVoid(); static Task<TResult> callInBackground(Callable<TResult> callable); static Task<TResult> callInBackground(Callable<TResult> callable, CancellationToken ct); static Task<TResult> call(final Callable<TResult> callable, Executor executor); static Task<TResult> call(final Callable<TResult> callable, Executor executor,
      final CancellationToken ct); static Task<TResult> call(final Callable<TResult> callable); static Task<TResult> call(final Callable<TResult> callable, CancellationToken ct); static Task<Task<TResult>> whenAnyResult(Collection<? extends Task<TResult>> tasks); @SuppressWarnings("unchecked") static Task<Task<?>> whenAny(Collection<? extends Task<?>> tasks); static Task<List<TResult>> whenAllResult(final Collection<? extends Task<TResult>> tasks); static Task<Void> whenAll(Collection<? extends Task<?>> tasks); Task<Void> continueWhile(Callable<Boolean> predicate,
      Continuation<Void, Task<Void>> continuation); Task<Void> continueWhile(Callable<Boolean> predicate,
      Continuation<Void, Task<Void>> continuation, CancellationToken ct); Task<Void> continueWhile(final Callable<Boolean> predicate,
      final Continuation<Void, Task<Void>> continuation, final Executor executor); Task<Void> continueWhile(final Callable<Boolean> predicate,
      final Continuation<Void, Task<Void>> continuation, final Executor executor,
      final CancellationToken ct); Task<TContinuationResult> continueWith(
      final Continuation<TResult, TContinuationResult> continuation, final Executor executor); Task<TContinuationResult> continueWith(
      final Continuation<TResult, TContinuationResult> continuation, final Executor executor,
      final CancellationToken ct); Task<TContinuationResult> continueWith(
      Continuation<TResult, TContinuationResult> continuation); Task<TContinuationResult> continueWith(
      Continuation<TResult, TContinuationResult> continuation, CancellationToken ct); Task<TContinuationResult> continueWithTask(
      final Continuation<TResult, Task<TContinuationResult>> continuation, final Executor executor); Task<TContinuationResult> continueWithTask(
      final Continuation<TResult, Task<TContinuationResult>> continuation, final Executor executor,
      final CancellationToken ct); Task<TContinuationResult> continueWithTask(
      Continuation<TResult, Task<TContinuationResult>> continuation); Task<TContinuationResult> continueWithTask(
      Continuation<TResult, Task<TContinuationResult>> continuation, CancellationToken ct); Task<TContinuationResult> onSuccess(
      final Continuation<TResult, TContinuationResult> continuation, Executor executor); Task<TContinuationResult> onSuccess(
      final Continuation<TResult, TContinuationResult> continuation, Executor executor,
      final CancellationToken ct); Task<TContinuationResult> onSuccess(
      final Continuation<TResult, TContinuationResult> continuation); Task<TContinuationResult> onSuccess(
      final Continuation<TResult, TContinuationResult> continuation, CancellationToken ct); Task<TContinuationResult> onSuccessTask(
      final Continuation<TResult, Task<TContinuationResult>> continuation, Executor executor); Task<TContinuationResult> onSuccessTask(
      final Continuation<TResult, Task<TContinuationResult>> continuation, Executor executor,
      final CancellationToken ct); Task<TContinuationResult> onSuccessTask(
      final Continuation<TResult, Task<TContinuationResult>> continuation); Task<TContinuationResult> onSuccessTask(
      final Continuation<TResult, Task<TContinuationResult>> continuation,
      CancellationToken ct); }
Task { public static void setUnobservedExceptionHandler(UnobservedExceptionHandler eh) { unobservedExceptionHandler = eh; } Task(); private  Task(TResult result); private  Task(boolean cancelled); static UnobservedExceptionHandler getUnobservedExceptionHandler(); static void setUnobservedExceptionHandler(UnobservedExceptionHandler eh); static Task<TResult>.TaskCompletionSource create(); boolean isCompleted(); boolean isCancelled(); boolean isFaulted(); TResult getResult(); Exception getError(); void waitForCompletion(); boolean waitForCompletion(long duration, TimeUnit timeUnit); @SuppressWarnings("unchecked") static Task<TResult> forResult(TResult value); static Task<TResult> forError(Exception error); @SuppressWarnings("unchecked") static Task<TResult> cancelled(); static Task<Void> delay(long delay); static Task<Void> delay(long delay, CancellationToken cancellationToken); Task<TOut> cast(); Task<Void> makeVoid(); static Task<TResult> callInBackground(Callable<TResult> callable); static Task<TResult> callInBackground(Callable<TResult> callable, CancellationToken ct); static Task<TResult> call(final Callable<TResult> callable, Executor executor); static Task<TResult> call(final Callable<TResult> callable, Executor executor,
      final CancellationToken ct); static Task<TResult> call(final Callable<TResult> callable); static Task<TResult> call(final Callable<TResult> callable, CancellationToken ct); static Task<Task<TResult>> whenAnyResult(Collection<? extends Task<TResult>> tasks); @SuppressWarnings("unchecked") static Task<Task<?>> whenAny(Collection<? extends Task<?>> tasks); static Task<List<TResult>> whenAllResult(final Collection<? extends Task<TResult>> tasks); static Task<Void> whenAll(Collection<? extends Task<?>> tasks); Task<Void> continueWhile(Callable<Boolean> predicate,
      Continuation<Void, Task<Void>> continuation); Task<Void> continueWhile(Callable<Boolean> predicate,
      Continuation<Void, Task<Void>> continuation, CancellationToken ct); Task<Void> continueWhile(final Callable<Boolean> predicate,
      final Continuation<Void, Task<Void>> continuation, final Executor executor); Task<Void> continueWhile(final Callable<Boolean> predicate,
      final Continuation<Void, Task<Void>> continuation, final Executor executor,
      final CancellationToken ct); Task<TContinuationResult> continueWith(
      final Continuation<TResult, TContinuationResult> continuation, final Executor executor); Task<TContinuationResult> continueWith(
      final Continuation<TResult, TContinuationResult> continuation, final Executor executor,
      final CancellationToken ct); Task<TContinuationResult> continueWith(
      Continuation<TResult, TContinuationResult> continuation); Task<TContinuationResult> continueWith(
      Continuation<TResult, TContinuationResult> continuation, CancellationToken ct); Task<TContinuationResult> continueWithTask(
      final Continuation<TResult, Task<TContinuationResult>> continuation, final Executor executor); Task<TContinuationResult> continueWithTask(
      final Continuation<TResult, Task<TContinuationResult>> continuation, final Executor executor,
      final CancellationToken ct); Task<TContinuationResult> continueWithTask(
      Continuation<TResult, Task<TContinuationResult>> continuation); Task<TContinuationResult> continueWithTask(
      Continuation<TResult, Task<TContinuationResult>> continuation, CancellationToken ct); Task<TContinuationResult> onSuccess(
      final Continuation<TResult, TContinuationResult> continuation, Executor executor); Task<TContinuationResult> onSuccess(
      final Continuation<TResult, TContinuationResult> continuation, Executor executor,
      final CancellationToken ct); Task<TContinuationResult> onSuccess(
      final Continuation<TResult, TContinuationResult> continuation); Task<TContinuationResult> onSuccess(
      final Continuation<TResult, TContinuationResult> continuation, CancellationToken ct); Task<TContinuationResult> onSuccessTask(
      final Continuation<TResult, Task<TContinuationResult>> continuation, Executor executor); Task<TContinuationResult> onSuccessTask(
      final Continuation<TResult, Task<TContinuationResult>> continuation, Executor executor,
      final CancellationToken ct); Task<TContinuationResult> onSuccessTask(
      final Continuation<TResult, Task<TContinuationResult>> continuation); Task<TContinuationResult> onSuccessTask(
      final Continuation<TResult, Task<TContinuationResult>> continuation,
      CancellationToken ct); static final ExecutorService BACKGROUND_EXECUTOR; static final Executor UI_THREAD_EXECUTOR; }