Skip to content

Commit cac0d94

Browse files
committed
Throw exception when flat object is null
The existing behavior throws an exception on null flat object by advancing the parser beyond the end of the flat object input. We could simply skip a null flat_object field, but this would be a behavioral change from 2.7. Signed-off-by: Michael Froh <[email protected]>
1 parent 02c12c6 commit cac0d94

File tree

1 file changed

+4
-1
lines changed

1 file changed

+4
-1
lines changed

server/src/main/java/org/opensearch/index/mapper/FlatObjectFieldMapper.java

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -568,6 +568,10 @@ protected void parseCreateField(ParseContext context) throws IOException {
568568
if (context.externalValueSet()) {
569569
String value = context.externalValue().toString();
570570
parseValueAddFields(context, value, fieldType().name());
571+
} else if (context.parser().currentToken() == XContentParser.Token.VALUE_NULL) {
572+
context.parser().nextToken(); // This triggers an exception in DocumentParser.
573+
// We could remove the above nextToken() call to skip the null value, but the existing
574+
// behavior (since 2.7) throws the exception.
571575
} else {
572576
JsonToStringXContentParser jsonToStringParser = new JsonToStringXContentParser(
573577
NamedXContentRegistry.EMPTY,
@@ -594,7 +598,6 @@ protected void parseCreateField(ParseContext context) throws IOException {
594598
}
595599

596600
}
597-
598601
}
599602

600603
}

0 commit comments

Comments
 (0)