All Downloads are FREE. Search and download functionalities are using the official Maven repository.

com.commercetools.http.asynchttp.ResponseAsyncCompletionHandler Maven / Gradle / Ivy

There is a newer version: 17.15.1
Show newest version

package com.commercetools.http.asynchttp;

import java.util.concurrent.CompletableFuture;

import org.asynchttpclient.AsyncCompletionHandler;
import org.asynchttpclient.Response;

final class ResponseAsyncCompletionHandler extends AsyncCompletionHandler {
    private final CompletableFuture future;

    ResponseAsyncCompletionHandler(final CompletableFuture future) {
        this.future = future;
    }

    @Override
    public Response onCompleted(final Response response) throws Exception {
        future.complete(response);
        return response;
    }

    @Override
    public void onThrowable(final Throwable t) {
        future.completeExceptionally(t);
        super.onThrowable(t);
    }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy