summaryrefslogtreecommitdiffstats
path: root/vespa-feed-client
diff options
context:
space:
mode:
authorJon Marius Venstad <venstad@gmail.com>2021-05-20 14:58:19 +0200
committerJon Marius Venstad <venstad@gmail.com>2021-05-20 14:58:19 +0200
commit5ab8437ccf6aaaa1cdc47555b6b7b1083b482237 (patch)
tree0419b3f9ef0a8f3f050bf9be588b0ae46c5e2490 /vespa-feed-client
parent560bb94804bd1508c1f93396de55366cec7cf2c8 (diff)
Fix silly bugs
Diffstat (limited to 'vespa-feed-client')
-rw-r--r--vespa-feed-client/src/main/java/com/yahoo/vespa/feed/client/DocumentId.java16
-rw-r--r--vespa-feed-client/src/main/java/com/yahoo/vespa/feed/client/HttpFeedClient.java6
2 files changed, 13 insertions, 9 deletions
diff --git a/vespa-feed-client/src/main/java/com/yahoo/vespa/feed/client/DocumentId.java b/vespa-feed-client/src/main/java/com/yahoo/vespa/feed/client/DocumentId.java
index 72a4f034bab..e00cedb293b 100644
--- a/vespa-feed-client/src/main/java/com/yahoo/vespa/feed/client/DocumentId.java
+++ b/vespa-feed-client/src/main/java/com/yahoo/vespa/feed/client/DocumentId.java
@@ -1,11 +1,8 @@
// Copyright Verizon Media. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root.
package com.yahoo.vespa.feed.client;
-import java.util.ArrayList;
-import java.util.List;
import java.util.Objects;
import java.util.Optional;
-import java.util.OptionalInt;
import java.util.OptionalLong;
import static java.util.Objects.requireNonNull;
@@ -30,15 +27,15 @@ public class DocumentId {
}
public static DocumentId of(String namespace, String documentType, String userSpecific) {
- return new DocumentId(namespace, documentType, OptionalLong.empty(), Optional.empty(), userSpecific);
+ return new DocumentId(documentType, namespace, OptionalLong.empty(), Optional.empty(), userSpecific);
}
public static DocumentId of(String namespace, String documentType, long number, String userSpecific) {
- return new DocumentId(namespace, documentType, OptionalLong.of(number), Optional.empty(), userSpecific);
+ return new DocumentId(documentType, namespace, OptionalLong.of(number), Optional.empty(), userSpecific);
}
public static DocumentId of(String namespace, String documentType, String group, String userSpecific) {
- return new DocumentId(namespace, documentType, OptionalLong.empty(), Optional.of(group), userSpecific);
+ return new DocumentId(documentType, namespace, OptionalLong.empty(), Optional.of(group), userSpecific);
}
public static DocumentId of(String serialized) {
@@ -89,4 +86,11 @@ public class DocumentId {
return Objects.hash(documentType, namespace, number, group, userSpecific);
}
+ @Override
+ public String toString() {
+ return "id:" + namespace + ":" + documentType + ":" +
+ (number.isPresent() ? "n=" + number.getAsLong() : group.map("g="::concat).orElse("")) +
+ ":" + userSpecific;
+ }
+
}
diff --git a/vespa-feed-client/src/main/java/com/yahoo/vespa/feed/client/HttpFeedClient.java b/vespa-feed-client/src/main/java/com/yahoo/vespa/feed/client/HttpFeedClient.java
index 39fcfd45a6f..58b9eef832b 100644
--- a/vespa-feed-client/src/main/java/com/yahoo/vespa/feed/client/HttpFeedClient.java
+++ b/vespa-feed-client/src/main/java/com/yahoo/vespa/feed/client/HttpFeedClient.java
@@ -123,12 +123,12 @@ class HttpFeedClient implements FeedClient {
private CompletableFuture<Result> send(String method, DocumentId documentId, String operationJson, OperationParameters params) {
SimpleHttpRequest request = new SimpleHttpRequest(method, operationUrl(endpoint, documentId, params));
- requestHeaders.forEach(request::setHeader);
+ requestHeaders.forEach((name, value) -> request.setHeader(name, value.get()));
if (operationJson != null)
request.setBody(operationJson, ContentType.APPLICATION_JSON);
return requestStrategy.enqueue(documentId, future -> {
- httpClient.execute(new SimpleHttpRequest(method, endpoint),
+ httpClient.execute(request,
new FutureCallback<SimpleHttpResponse>() {
@Override public void completed(SimpleHttpResponse response) { future.complete(response); }
@Override public void failed(Exception ex) { future.completeExceptionally(ex); }
@@ -154,7 +154,7 @@ class HttpFeedClient implements FeedClient {
default: type = failure;
}
Map<String, String> responseJson = null; // TODO: parse JSON.
- return new Result(type, documentId, responseJson.get("message"), responseJson.get("trace"));
+ return new Result(type, documentId, response.getBodyText(), "trace");
}
static List<String> toPath(DocumentId documentId) {