aboutsummaryrefslogtreecommitdiffstats
path: root/vespa-feed-client
diff options
context:
space:
mode:
Diffstat (limited to 'vespa-feed-client')
-rw-r--r--vespa-feed-client/src/main/java/ai/vespa/feed/client/HttpFeedClient.java17
1 files changed, 15 insertions, 2 deletions
diff --git a/vespa-feed-client/src/main/java/ai/vespa/feed/client/HttpFeedClient.java b/vespa-feed-client/src/main/java/ai/vespa/feed/client/HttpFeedClient.java
index 143f51a9bf7..6e0d9aa5ec2 100644
--- a/vespa-feed-client/src/main/java/ai/vespa/feed/client/HttpFeedClient.java
+++ b/vespa-feed-client/src/main/java/ai/vespa/feed/client/HttpFeedClient.java
@@ -12,6 +12,7 @@ import java.util.HashMap;
import java.util.Map;
import java.util.StringJoiner;
import java.util.concurrent.CompletableFuture;
+import java.util.concurrent.CompletionException;
import java.util.concurrent.atomic.AtomicBoolean;
import java.util.function.Supplier;
@@ -84,8 +85,20 @@ class HttpFeedClient implements FeedClient {
requestHeaders,
operationJson == null ? null : operationJson.getBytes(UTF_8)); // TODO: make it bytes all the way?
- return requestStrategy.enqueue(documentId, request)
- .thenApply(response -> toResult(request, response, documentId));
+ CompletableFuture<Result> promise = new CompletableFuture<>();
+ requestStrategy.enqueue(documentId, request)
+ .thenApply(response -> toResult(request, response, documentId))
+ .whenComplete((result, thrown) -> {
+ if (thrown != null) {
+ while (thrown instanceof CompletionException)
+ thrown = thrown.getCause();
+
+ promise.completeExceptionally(thrown);
+ }
+ else
+ promise.complete(result);
+ });
+ return promise;
}
private enum Outcome { success, conditionNotMet, vespaFailure, transportFailure };