public abstract class AbstractCheckedFuture<T,E extends Exception> extends org.apache.drill.shaded.guava.com.google.common.util.concurrent.ForwardingListenableFuture.SimpleForwardingListenableFuture<T> implements CheckedFuture<T,E>
ListenableFuture that adds support for the checkedGet() and checkedGet(long, TimeUnit) methods.
This class is moved from Guava, since there it was deleted.| Modifier | Constructor and Description |
|---|---|
protected |
AbstractCheckedFuture(org.apache.drill.shaded.guava.com.google.common.util.concurrent.ListenableFuture<T> delegate) |
| Modifier and Type | Method and Description |
|---|---|
T |
checkedGet()
Exception checking version of
Future.get() that will translate
InterruptedException, CancellationException and
ExecutionException into application-specific exceptions. |
T |
checkedGet(long timeout,
TimeUnit unit)
Exception checking version of
Future.get(long, TimeUnit) that will
translate InterruptedException, CancellationException and
ExecutionException into application-specific exceptions. |
protected abstract E |
mapException(Exception e)
Translates from an
InterruptedException,
CancellationException or ExecutionException thrown by
get to an exception of type X to be thrown by
checkedGet. |
delegateaddListenercancel, get, get, isCancelled, isDonetoStringclone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, waitprotected AbstractCheckedFuture(org.apache.drill.shaded.guava.com.google.common.util.concurrent.ListenableFuture<T> delegate)
protected abstract E mapException(Exception e)
InterruptedException,
CancellationException or ExecutionException thrown by
get to an exception of type X to be thrown by
checkedGet. Subclasses must implement this method.
If e is an InterruptedException, the calling
checkedGet method has already restored the interrupt after catching
the exception. If an implementation of mapException(Exception)
wishes to swallow the interrupt, it can do so by calling
Thread.interrupted().
Subclasses may choose to throw, rather than return, a subclass of
RuntimeException to allow creating a CheckedFuture that throws
both checked and unchecked exceptions.
public T checkedGet() throws E extends Exception
Future.get() that will translate
InterruptedException, CancellationException and
ExecutionException into application-specific exceptions.checkedGet in interface CheckedFuture<T,E extends Exception>E - on interruption, cancellation or execution exceptions.E extends Exceptionpublic T checkedGet(long timeout, TimeUnit unit) throws TimeoutException, E extends Exception
Future.get(long, TimeUnit) that will
translate InterruptedException, CancellationException and
ExecutionException into application-specific exceptions. On
timeout this method throws a normal TimeoutException.checkedGet in interface CheckedFuture<T,E extends Exception>TimeoutException - if retrieving the result timed out.E - on interruption, cancellation or execution exceptions.E extends ExceptionCopyright © 2021 The Apache Software Foundation. All rights reserved.