summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--document/src/main/java/com/yahoo/document/json/JsonFeedReader.java1
-rw-r--r--document/src/main/java/com/yahoo/document/json/JsonReader.java1
-rw-r--r--document/src/test/java/com/yahoo/document/json/JsonReaderTestCase.java48
-rw-r--r--vespaclient-container-plugin/src/main/java/com/yahoo/vespa/http/server/ClientFeederV3.java13
4 files changed, 58 insertions, 5 deletions
diff --git a/document/src/main/java/com/yahoo/document/json/JsonFeedReader.java b/document/src/main/java/com/yahoo/document/json/JsonFeedReader.java
index ec0d29a53a6..1b5681e7146 100644
--- a/document/src/main/java/com/yahoo/document/json/JsonFeedReader.java
+++ b/document/src/main/java/com/yahoo/document/json/JsonFeedReader.java
@@ -23,6 +23,7 @@ import com.yahoo.vespaxmlparser.VespaXMLFeedReader.Operation;
* @author steinar
*/
public class JsonFeedReader implements FeedReader {
+
private final JsonReader reader;
private InputStream stream;
private static final JsonFactory jsonFactory = new JsonFactory().disable(JsonFactory.Feature.CANONICALIZE_FIELD_NAMES);
diff --git a/document/src/main/java/com/yahoo/document/json/JsonReader.java b/document/src/main/java/com/yahoo/document/json/JsonReader.java
index bedfbdc3da5..6b4605623b3 100644
--- a/document/src/main/java/com/yahoo/document/json/JsonReader.java
+++ b/document/src/main/java/com/yahoo/document/json/JsonReader.java
@@ -79,6 +79,7 @@ public class JsonReader {
return operation;
}
+ /** Returns the next document operation, or null if we have reached the end */
public DocumentOperation next() {
switch (state) {
case AT_START:
diff --git a/document/src/test/java/com/yahoo/document/json/JsonReaderTestCase.java b/document/src/test/java/com/yahoo/document/json/JsonReaderTestCase.java
index 07f0a172caf..443ff27cd20 100644
--- a/document/src/test/java/com/yahoo/document/json/JsonReaderTestCase.java
+++ b/document/src/test/java/com/yahoo/document/json/JsonReaderTestCase.java
@@ -1094,6 +1094,54 @@ public class JsonReaderTestCase {
new JsonReader(types, jsonToInputStream(jsonData), parserFactory).next();
}
+ @Test
+ public void testMissingOperation() {
+ try {
+ String jsonData = inputJson(
+ "[",
+ " {",
+ " 'fields': {",
+ " 'actualarray': {",
+ " 'add': [",
+ " 'person',",
+ " 'another person'",
+ " ]",
+ " }",
+ " }",
+ " }",
+ "]");
+
+ new JsonReader(types, jsonToInputStream(jsonData), parserFactory).next();
+ }
+ catch (IllegalArgumentException e) {
+ assertEquals("", e.getMessage());
+ }
+ }
+
+ @Test
+ public void testMissingFieldsMap() { todo ...
+ try {
+ String jsonData = inputJson(
+ "[",
+ " {",
+ " 'fields': {",
+ " 'actualarray': {",
+ " 'add': [",
+ " 'person',",
+ " 'another person'",
+ " ]",
+ " }",
+ " }",
+ " }",
+ "]");
+
+ new JsonReader(types, jsonToInputStream(jsonData), parserFactory).next();
+ }
+ catch (IllegalArgumentException e) {
+ assertEquals("", e.getMessage());
+ }
+ }
+
static ByteArrayInputStream jsonToInputStream(String json) {
return new ByteArrayInputStream(Utf8.toBytes(json));
}
diff --git a/vespaclient-container-plugin/src/main/java/com/yahoo/vespa/http/server/ClientFeederV3.java b/vespaclient-container-plugin/src/main/java/com/yahoo/vespa/http/server/ClientFeederV3.java
index 5f1c96d000f..0d8cde234eb 100644
--- a/vespaclient-container-plugin/src/main/java/com/yahoo/vespa/http/server/ClientFeederV3.java
+++ b/vespaclient-container-plugin/src/main/java/com/yahoo/vespa/http/server/ClientFeederV3.java
@@ -40,6 +40,8 @@ import static com.yahoo.messagebus.ErrorCode.SEND_QUEUE_FULL;
* The implementation is based on the code from V2, but the object model is rewritten to simplify the logic and
* avoid using a threadpool that has no effect with all the extra that comes with it. V2 has one instance per thread
* on the client, while this is one instance for all threads.
+ *
+ * @author dybis
*/
class ClientFeederV3 {
@@ -109,7 +111,7 @@ class ClientFeederV3 {
ongoingRequests.incrementAndGet();
try {
FeederSettings feederSettings = new FeederSettings(request);
- /**
+ /*
* The gateway handle overload from clients in different ways.
*
* If the backend is overloaded, but not the gateway, it will fill the backend, messagebus throttler
@@ -132,7 +134,7 @@ class ClientFeederV3 {
}
InputStream inputStream = StreamReaderV3.unzipStreamIfNeeded(request);
- final BlockingQueue<OperationStatus> replies = new LinkedBlockingQueue<>();
+ BlockingQueue<OperationStatus> replies = new LinkedBlockingQueue<>();
try {
feed(feederSettings, inputStream, replies, threadsAvailableForFeeding);
synchronized (monitor) {
@@ -171,7 +173,7 @@ class ClientFeederV3 {
private Optional<DocumentOperationMessageV3> pullMessageFromRequest(
FeederSettings settings, InputStream requestInputStream, BlockingQueue<OperationStatus> repliesFromOldMessages) {
while (true) {
- final Optional<String> operationId;
+ Optional<String> operationId;
try {
operationId = streamReaderV3.getNextOperationId(requestInputStream);
} catch (IOException ioe) {
@@ -183,7 +185,7 @@ class ClientFeederV3 {
if (! operationId.isPresent()) {
return Optional.empty();
}
- final DocumentOperationMessageV3 msg;
+ DocumentOperationMessageV3 msg;
try {
msg = getNextMessage(operationId.get(), requestInputStream, settings);
} catch (Exception e) {
@@ -235,7 +237,7 @@ class ClientFeederV3 {
}
setMessageParameters(msg.get(), settings);
- final Result result;
+ Result result;
try {
result = sendMessage(settings, msg.get(), threadsAvailableForFeeding);
@@ -286,6 +288,7 @@ class ClientFeederV3 {
}
DocumentOperationMessageV3 msg = DocumentOperationMessageV3.create(operation, operationId, metric);
+ xxx
if (msg == null) {
// typical end of feed
return null;