#9444 throw StrictDynamicMappingException exception if dynamic is 'strict' and undeclared field value is NULL, test for this

Fixes #9445
This commit is contained in:
simaov 2015-01-27 16:49:40 +02:00 committed by Jordan Sissel
parent 39c064ce8b
commit f3e1a66133
2 changed files with 15 additions and 0 deletions

View File

@ -587,6 +587,10 @@ public class ObjectMapper implements Mapper, AllFieldMapper.IncludeInAll {
}
}
mapper.parse(context);
} else {
if (dynamic == Dynamic.STRICT) {
throw new StrictDynamicMappingException(fullPath, lastFieldName);
}
}
}

View File

@ -98,6 +98,17 @@ public class DynamicMappingTests extends ElasticsearchSingleNodeTest {
} catch (StrictDynamicMappingException e) {
// all is well
}
try {
defaultMapper.parse("type", "1", XContentFactory.jsonBuilder()
.startObject()
.field("field1", "value1")
.field("field2", (String) null)
.bytes());
fail();
} catch (StrictDynamicMappingException e) {
// all is well
}
}
@Test