NPE when the JSON to index doesn't match the mapping's expectations, closes #795.
This commit is contained in:
parent
70fc8d9af0
commit
fb7fbc8c83
|
@ -295,6 +295,8 @@ public class ObjectMapper implements XContentMapper, IncludeInAllMapper {
|
||||||
if (token == XContentParser.Token.START_OBJECT) {
|
if (token == XContentParser.Token.START_OBJECT) {
|
||||||
// if we are just starting an OBJECT, advance, this is the object we are parsing, we need the name first
|
// if we are just starting an OBJECT, advance, this is the object we are parsing, we need the name first
|
||||||
token = parser.nextToken();
|
token = parser.nextToken();
|
||||||
|
} else if (token.isValue()) {
|
||||||
|
throw new MapperParsingException("object_mapper [" + name + "] expected object type, but got value [" + token + "]");
|
||||||
}
|
}
|
||||||
while (token != XContentParser.Token.END_OBJECT) {
|
while (token != XContentParser.Token.END_OBJECT) {
|
||||||
if (token == XContentParser.Token.START_OBJECT) {
|
if (token == XContentParser.Token.START_OBJECT) {
|
||||||
|
@ -305,6 +307,8 @@ public class ObjectMapper implements XContentMapper, IncludeInAllMapper {
|
||||||
currentFieldName = parser.currentName();
|
currentFieldName = parser.currentName();
|
||||||
} else if (token == XContentParser.Token.VALUE_NULL) {
|
} else if (token == XContentParser.Token.VALUE_NULL) {
|
||||||
serializeNullValue(context, currentFieldName);
|
serializeNullValue(context, currentFieldName);
|
||||||
|
} else if (token == null) {
|
||||||
|
throw new MapperParsingException("object_mapper [" + name + "] tried to parse as object, but got EOF");
|
||||||
} else if (token.isValue()) {
|
} else if (token.isValue()) {
|
||||||
serializeValue(context, currentFieldName, token);
|
serializeValue(context, currentFieldName, token);
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue