com.commercetools.http.asynchttp.ResponseAsyncCompletionHandler Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of commercetools-async-http-client Show documentation
Show all versions of commercetools-async-http-client Show documentation
The e-commerce SDK from commercetools Composable Commerce for Java
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);
}
}