Class AbstractCheckedFuture<V,​E extends Exception>

  • All Implemented Interfaces:
    com.google.common.util.concurrent.ListenableFuture<V>, Future<V>, CheckedFuture<V,​E>
    Direct Known Subclasses:
    ImmediateFuture

    public abstract class AbstractCheckedFuture<V,​E extends Exception>
    extends Object
    implements CheckedFuture<V,​E>
    An abstract decorator on ListenableFuture which adds checkedGet() methods which simplify Future's error handling. Exceptions originating from the future computation are extracted from the ExecutionException wrapper, and passed to the implementation's exception mapper, which is responsible for mapping to the proper exception of type E. Unless really required, it's strongly recommended to handle wrapped runtime exceptions differently than checked exceptions. They should be preserved and thrown unchanged, since they usually denote a bug. This class implements the CheckedFuture interface, which is a replacement for Google's deprecated CheckedFuture.
    Author:
    Eyal Schneider