public final class FutureHelper
extends java.lang.Object
Futures
in the synchronous datastore api.Constructor and Description |
---|
FutureHelper() |
Modifier and Type | Method and Description |
---|---|
static <T> T |
quietGet(java.util.concurrent.Future<T> future)
Return the result of the provided
Future , converting all checked exceptions to
unchecked exceptions so the caller doesn't have to handle them. |
static <T,E extends java.lang.Exception> |
quietGet(java.util.concurrent.Future<T> future,
java.lang.Class<E> exceptionClass)
Return the result of the provided
Future , converting all checked exceptions except
those of the provided type to unchecked exceptions so the caller doesn't have to handle them. |
public static <T> T quietGet(java.util.concurrent.Future<T> future)
Future
, converting all checked exceptions to
unchecked exceptions so the caller doesn't have to handle them. If an ExecutionException
is thrown the cause is wrapped in a RuntimeException
. If an InterruptedException
is thrown it is wrapped in a DatastoreFailureException
.T
- The type of the provided Future.future
- The Future whose result we want to return.public static <T,E extends java.lang.Exception> T quietGet(java.util.concurrent.Future<T> future, java.lang.Class<E> exceptionClass) throws E extends java.lang.Exception
Future
, converting all checked exceptions except
those of the provided type to unchecked exceptions so the caller doesn't have to handle them.
If an ExecutionException
is thrown and the type of the cause does
not equal exceptionClass
the cause is wrapped in a RuntimeException
. If the
type of the cause does equal exceptionClass
the cause itself is thrown. If an InterruptedException
is thrown it is wrapped in a DatastoreFailureException
.T
- The type of the provided Future.future
- The Future whose result we want to return.exceptionClass
- Exceptions of this type will be rethrown.E
- Thrown If an ExecutionException with a cause of the appropriate type is caught.E extends java.lang.Exception