@Override protected <T> ListenableFuture<T> doExecute(URI url, HttpMethod method, AsyncRequestCallback requestCallback, ResponseExtractor<T> responseExtractor) throws RestClientException { try { return super.doExecute(url, method, requestCallback, responseExtractor); } finally { finish(); } }
public <T> CompletableFuture<T> execute(String url, HttpMethod method, AsyncRequestCallback requestCallback, ResponseExtractor<T> responseExtractor, Object... urlVariables) throws RestClientException { return toCompletableFuture(template.execute(url, method, requestCallback, responseExtractor, urlVariables)); }
public <T> CompletableFuture<T> execute(String url, HttpMethod method, AsyncRequestCallback requestCallback, ResponseExtractor<T> responseExtractor, Map<String, ?> urlVariables) throws RestClientException { return toCompletableFuture(template.execute(url, method, requestCallback, responseExtractor, urlVariables)); }
public <T> CompletableFuture<T> execute(URI url, HttpMethod method, AsyncRequestCallback requestCallback, ResponseExtractor<T> responseExtractor) throws RestClientException { return toCompletableFuture(template.execute(url, method, requestCallback, responseExtractor)); }
@Override protected <T> ListenableFuture<T> doExecute(URI url, HttpMethod method, AsyncRequestCallback requestCallback, ResponseExtractor<T> responseExtractor) throws RestClientException { final ListenableFuture<T> future = super.doExecute(url, method, requestCallback, responseExtractor); final Span span = this.tracer.getCurrentSpan(); future.addCallback(new TraceListenableFutureCallback<>(this.tracer, span, this.errorParser)); // potential race can happen here if (span != null && span.equals(this.tracer.getCurrentSpan())) { Span parent = this.tracer.detach(span); if (parent != null) { this.tracer.continueSpan(parent); } } return new ListenableFuture<T>() { @Override public boolean cancel(boolean mayInterruptIfRunning) { return future.cancel(mayInterruptIfRunning); } @Override public boolean isCancelled() { return future.isCancelled(); } @Override public boolean isDone() { return future.isDone(); } @Override public T get() throws InterruptedException, ExecutionException { return future.get(); } @Override public T get(long timeout, TimeUnit unit) throws InterruptedException, ExecutionException, TimeoutException { return future.get(timeout, unit); } @Override public void addCallback(ListenableFutureCallback<? super T> callback) { future.addCallback(new TraceListenableFutureCallbackWrapper<>(TraceAsyncRestTemplate.this.tracer, span, callback)); } @Override public void addCallback(SuccessCallback<? super T> successCallback, FailureCallback failureCallback) { future.addCallback( new TraceSuccessCallback<>(TraceAsyncRestTemplate.this.tracer, span, successCallback), new TraceFailureCallback(TraceAsyncRestTemplate.this.tracer, span, failureCallback)); } }; }