in src/main/java/com/spotify/github/http/okhttp/OkHttpHttpClient.java [72:102]
public CompletableFuture<HttpResponse> send(final HttpRequest httpRequest) {
Request request = buildOkHttpRequest(httpRequest);
CompletableFuture<HttpResponse> future = new CompletableFuture<>();
try (Span span = tracer.span(httpRequest)) {
if (this.callFactory == null) {
this.callFactory = createTracedClient();
}
tracer.attachSpanToFuture(span, future);
try {
this.callFactory
.newCall(request)
.enqueue(
new Callback() {
@Override
public void onResponse(@NotNull final Call call, @NotNull final Response response)
throws IOException {
future.complete(new OkHttpHttpResponse(httpRequest, response));
}
@Override
public void onFailure(@NotNull final Call call, @NotNull final IOException e) {
future.completeExceptionally(e);
}
});
} catch (Exception e) {
future.completeExceptionally(e);
}
}
return future;
}