/** * Calls {@link Future#get()} without the checked exceptions. * * @param future to dereference * @param <T> the type returned * @return the value of the future */ public static <T> T get(Future<T> future) { try { return future.get(); } catch (InterruptedException e) { Thread.currentThread().interrupt(); throw new IllegalStateException("Future got interrupted", e); } catch (ExecutionException e) { throw rethrowExecutionException(e); } }
/** * Calls {@link Future#get(long, TimeUnit)} without the checked exceptions. * * @param future to dereference * @param timeout to wait * @param unit for timeout * @param <T> the type returned * @return the value of the future */ public static <T> T get(Future<T> future, long timeout, TimeUnit unit) { try { return future.get(timeout, unit); } catch (TimeoutException e) { throw new ElasticsearchTimeoutException(e); } catch (InterruptedException e) { Thread.currentThread().interrupt(); throw new IllegalStateException("Future got interrupted", e); } catch (ExecutionException e) { throw FutureUtils.rethrowExecutionException(e); } }
/** * Calls {@link Future#get()} without the checked exceptions. * * @param future to dereference * @param <T> the type returned * @return the value of the future */ public static <T> T get(Future<T> future) { try { return future.get(); } catch (InterruptedException e) { Thread.currentThread().interrupt(); throw new IllegalStateException("Future got interrupted", e); } catch (ExecutionException e) { throw rethrowExecutionException(e); } }
/** * Calls {@link Future#get(long, TimeUnit)} without the checked exceptions. * * @param future to dereference * @param timeout to wait * @param unit for timeout * @param <T> the type returned * @return the value of the future */ public static <T> T get(Future<T> future, long timeout, TimeUnit unit) { try { return future.get(timeout, unit); } catch (TimeoutException e) { throw new ElasticsearchTimeoutException(e); } catch (InterruptedException e) { Thread.currentThread().interrupt(); throw new IllegalStateException("Future got interrupted", e); } catch (ExecutionException e) { throw FutureUtils.rethrowExecutionException(e); } }
throw new IllegalStateException("Future got interrupted", e); } catch (ExecutionException e) { throw rethrowExecutionException(e); throw new IllegalStateException("Future got interrupted", e); } catch (ExecutionException e) { throw FutureUtils.rethrowExecutionException(e);