@Test public void whenTaskThrowsThenThrowExecutionException() throws InterruptedException { CompletableFutureTask<Integer> task = CompletableFutureTask.runAsync(() -> { throw new MyException(); }, executor); try { task.get(); fail(); } catch (ExecutionException exc) { assertTrue(exc.getCause() instanceof MyException); } }
public CompletableFutureTask<R> runAsync(Executor executor) { executor.execute(this); return this; }
CompletableFutureTask extends CompletableFuture<R> implements Runnable { public CompletableFutureTask<R> runAsync(Executor executor) { executor.execute(this); return this; } }
CompletableFutureTask extends CompletableFuture<R> implements Runnable { public CompletableFutureTask<R> runAsync(Executor executor) { executor.execute(this); return this; } CompletableFutureTask(Callable<R> task); }
CompletableFutureTask extends CompletableFuture<R> implements Runnable { public CompletableFutureTask<R> runAsync(Executor executor) { executor.execute(this); return this; } CompletableFutureTask(Callable<R> task); @Override void run(); CompletableFutureTask<R> runAsync(Executor executor); static CompletableFutureTask<T> runAsync(Callable<T> task, Executor executor); @Override boolean cancel(boolean mayInterruptIfRunning); }
CompletableFutureTask extends CompletableFuture<R> implements Runnable { public CompletableFutureTask<R> runAsync(Executor executor) { executor.execute(this); return this; } CompletableFutureTask(Callable<R> task); @Override void run(); CompletableFutureTask<R> runAsync(Executor executor); static CompletableFutureTask<T> runAsync(Callable<T> task, Executor executor); @Override boolean cancel(boolean mayInterruptIfRunning);  }