summaryrefslogtreecommitdiffstats
path: root/vespa-http-client
diff options
context:
space:
mode:
authorHarshil Shukla <harshil@oath.com>2019-04-30 15:17:59 -0700
committerHarshil Shukla <harshil@oath.com>2019-04-30 15:17:59 -0700
commitd618d1442bc1963de08e843ef14c49f12ae7e9d9 (patch)
treed352d1f57cfd741efd6559ecd4c5882d2dbd4f26 /vespa-http-client
parente6fdabe56914c6ff1ec554ff433efd8adcdb8c83 (diff)
Allow client to pass custom operationId
Diffstat (limited to 'vespa-http-client')
-rw-r--r--vespa-http-client/src/main/java/com/yahoo/vespa/http/client/SyncFeedClient.java11
-rw-r--r--vespa-http-client/src/test/java/com/yahoo/vespa/http/client/SyncFeedClientTest.java4
2 files changed, 7 insertions, 8 deletions
diff --git a/vespa-http-client/src/main/java/com/yahoo/vespa/http/client/SyncFeedClient.java b/vespa-http-client/src/main/java/com/yahoo/vespa/http/client/SyncFeedClient.java
index c4b9b1161b7..8acdec334d0 100644
--- a/vespa-http-client/src/main/java/com/yahoo/vespa/http/client/SyncFeedClient.java
+++ b/vespa-http-client/src/main/java/com/yahoo/vespa/http/client/SyncFeedClient.java
@@ -62,19 +62,18 @@ public class SyncFeedClient implements AutoCloseable {
private final String operationId;
public SyncOperation(String documentId, CharSequence documentData) {
- this(documentId, documentData, null, null);
+ this(documentId, documentData, null);
}
- public SyncOperation(String documentId, CharSequence documentData, String operationId) {
- this(documentId, documentData, operationId, null);
+ public SyncOperation(String documentId, CharSequence documentData, Object context) {
+ this(documentId, documentData, new BigInteger(64, ThreadLocalRandom.current()).toString(32), context);
}
- private SyncOperation(String documentId, CharSequence documentData, String operationId, Object context) {
+ public SyncOperation(String documentId, CharSequence documentData, String operationId, Object context) {
this.documentId = Objects.requireNonNull(documentId, "documentId");
this.documentData = Objects.requireNonNull(documentData, "documentData");
this.context = context;
- this.operationId = Objects.isNull(operationId) ?
- new BigInteger(64, ThreadLocalRandom.current()).toString(32) : operationId;
+ this.operationId = Objects.requireNonNull(operationId);
}
}
diff --git a/vespa-http-client/src/test/java/com/yahoo/vespa/http/client/SyncFeedClientTest.java b/vespa-http-client/src/test/java/com/yahoo/vespa/http/client/SyncFeedClientTest.java
index 562341d6d2a..a2d5b18999e 100644
--- a/vespa-http-client/src/test/java/com/yahoo/vespa/http/client/SyncFeedClientTest.java
+++ b/vespa-http-client/src/test/java/com/yahoo/vespa/http/client/SyncFeedClientTest.java
@@ -79,14 +79,14 @@ public class SyncFeedClientTest {
" \"fields\": {" +
" \"title\": \"Title 4\"" +
" }" +
- "}", "opId_4"));
+ "}", "opId_4", null));
operations.add(new SyncOperation("id::test::4", // Another operation for the same document
"{" +
" \"put\": \"id::test::4\"," +
" \"fields\": {" +
" \"title\": \"Title 44\"" +
" }" +
- "}", "opId_44"));
+ "}", "opId_44", null));
SyncResult result = feedClient.stream(operations);