@Test(expected = IllegalStateException.class) public void testCheckExceptions() throws Throwable { ExecutorService executor = Executors.newSingleThreadExecutor(); Future<Object> future = executor.submit(new Callable<Object>() { @Override public Void call() throws IOException { throw new IOException(); } }); ExecutorUtils.checkExceptions(Collections.singletonList(future)); }
public static <T> void checkExceptions(Iterable<Future<T>> futures) { for (Future<?> future : futures) { try { future.get(); } catch (InterruptedException e) { throw new IllegalStateException(e); } catch (ExecutionException e) { throw new IllegalStateException(e.getCause()); } } }
ExecutorUtils { public static <T> void checkExceptions(Iterable<Future<T>> futures) { for (Future<?> future : futures) { try { future.get(); } catch (InterruptedException e) { throw new IllegalStateException(e); } catch (ExecutionException e) { throw new IllegalStateException(e.getCause()); } } } }
ExecutorUtils { public static <T> void checkExceptions(Iterable<Future<T>> futures) { for (Future<?> future : futures) { try { future.get(); } catch (InterruptedException e) { throw new IllegalStateException(e); } catch (ExecutionException e) { throw new IllegalStateException(e.getCause()); } } } private  ExecutorUtils(); }
ExecutorUtils { public static <T> void checkExceptions(Iterable<Future<T>> futures) { for (Future<?> future : futures) { try { future.get(); } catch (InterruptedException e) { throw new IllegalStateException(e); } catch (ExecutionException e) { throw new IllegalStateException(e.getCause()); } } } private  ExecutorUtils(); static int getParallelism(); static void shutdownNowAndAwait(ExecutorService executor); static void shutdownAndAwait(ExecutorService executor); static void checkExceptions(Iterable<Future<T>> futures); }
ExecutorUtils { public static <T> void checkExceptions(Iterable<Future<T>> futures) { for (Future<?> future : futures) { try { future.get(); } catch (InterruptedException e) { throw new IllegalStateException(e); } catch (ExecutionException e) { throw new IllegalStateException(e.getCause()); } } } private  ExecutorUtils(); static int getParallelism(); static void shutdownNowAndAwait(ExecutorService executor); static void shutdownAndAwait(ExecutorService executor); static void checkExceptions(Iterable<Future<T>> futures);  }