From 5ab8437ccf6aaaa1cdc47555b6b7b1083b482237 Mon Sep 17 00:00:00 2001 From: Jon Marius Venstad Date: Thu, 20 May 2021 14:58:19 +0200 Subject: Fix silly bugs --- .../java/com/yahoo/vespa/feed/client/DocumentId.java | 16 ++++++++++------ .../java/com/yahoo/vespa/feed/client/HttpFeedClient.java | 6 +++--- 2 files changed, 13 insertions(+), 9 deletions(-) (limited to 'vespa-feed-client') 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 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() { @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 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 toPath(DocumentId documentId) { -- cgit v1.2.3