Search in sources :

Example 1 with SdkCancellationException

use of software.amazon.awssdk.http.SdkCancellationException in project aws-sdk-java-v2 by aws.

the class CrtRequestExecutor method createExecutionFuture.

/**
 * Convenience method to create the execution future and set up the cancellation logic.
 *
 * @return The created execution future.
 */
private CompletableFuture<Void> createExecutionFuture(AsyncExecuteRequest request) {
    CompletableFuture<Void> future = new CompletableFuture<>();
    future.whenComplete((r, t) -> {
        if (t == null) {
            return;
        }
        // TODO: Aborting request once it's supported in CRT
        if (future.isCancelled()) {
            request.responseHandler().onError(new SdkCancellationException("The request was cancelled"));
        }
    });
    return future;
}
Also used : CompletableFuture(java.util.concurrent.CompletableFuture) SdkCancellationException(software.amazon.awssdk.http.SdkCancellationException)

Aggregations

CompletableFuture (java.util.concurrent.CompletableFuture)1 SdkCancellationException (software.amazon.awssdk.http.SdkCancellationException)1