Class FailedFuture<V>

All Implemented Interfaces:
Future<V>, Future<V>

public final class FailedFuture<V> extends CompleteFuture<V>
The CompleteFuture which is failed already. It is recommended to use EventExecutor.newFailedFuture(Throwable) instead of calling the constructor of this future.
  • Field Details

  • Constructor Details

    • FailedFuture

      public FailedFuture(EventExecutor executor, Throwable cause)
      Creates a new instance.
      Parameters:
      executor - the EventExecutor associated with this future
      cause - the cause of failure
  • Method Details

    • cause

      public Throwable cause()
      Description copied from interface: Future
      Returns the cause of the failed I/O operation if the I/O operation has failed.
      Returns:
      the cause of the failure. null if succeeded or this future is not completed yet.
    • isSuccess

      public boolean isSuccess()
      Description copied from interface: Future
      Returns true if and only if the I/O operation was completed successfully.
    • sync

      public Future<V> sync()
      Description copied from interface: Future
      Waits for this future until it is done, and rethrows the cause of the failure if this future failed.
      Specified by:
      sync in interface Future<V>
      Overrides:
      sync in class CompleteFuture<V>
    • syncUninterruptibly

      public Future<V> syncUninterruptibly()
      Description copied from interface: Future
      Waits for this future until it is done, and rethrows the cause of the failure if this future failed.
      Specified by:
      syncUninterruptibly in interface Future<V>
      Overrides:
      syncUninterruptibly in class CompleteFuture<V>
    • getNow

      public V getNow()
      Description copied from interface: Future
      Return the result without blocking. If the future is not done yet this will return null.

      As it is possible that a null value is used to mark the future as successful you also need to check if the future is really done with Future.isDone() and not rely on the returned null value.