Class BlockingUtils

java.lang.Object
io.servicetalk.concurrent.api.internal.BlockingUtils

public final class BlockingUtils extends Object
Common utility functions to unwrap ExecutionException from async operations.
  • Method Details

    • futureGetCancelOnInterrupt

      public static <T> T futureGetCancelOnInterrupt(Future<T> future) throws Exception
      Completes a Future by invoking Future.get(). Any occurred Exception will be converted to unchecked, and ExecutionExceptions will be unwrapped. Upon interruption, the Future is cancelled.
      Type Parameters:
      T - The type of the result.
      Parameters:
      future - The future to operate on.
      Returns:
      The result of the future.
      Throws:
      Exception - InterrupedException upon interruption or unchecked exceptions for any other exception.
    • blockingInvocation

      public static <T> T blockingInvocation(Single<T> source) throws Exception
      Subscribes a Single immediately and awaits result. Any occurred Exception will be converted to unchecked, and ExecutionExceptions will be unwrapped.
      Type Parameters:
      T - The type of the result.
      Parameters:
      source - The Single to operate on.
      Returns:
      The result of the single.
      Throws:
      Exception - InterrupedException upon interruption or unchecked exceptions for any other exception.
    • blockingInvocation

      public static void blockingInvocation(Completable source) throws Exception
      Subscribes a Completable immediately and awaits result. Any occurred Exception will be converted to unchecked, and ExecutionExceptions will be unwrapped.
      Parameters:
      source - The Completable to operate on.
      Throws:
      Exception - unchecked exceptions for any exception that occurs.