Assertion handling timestamp in index request

This commit adds an assertion that the mapping metadata is not null when
handling a non-default timestamp when no timestamp is provided.

Closes #16596
This commit is contained in:
Jason Tedor 2016-02-14 14:34:26 -05:00
parent cca611171c
commit d313cdd7d0
1 changed files with 6 additions and 0 deletions

View File

@ -626,6 +626,12 @@ public class IndexRequest extends ReplicationRequest<IndexRequest> implements Do
if (defaultTimestamp.equals(TimestampFieldMapper.Defaults.DEFAULT_TIMESTAMP)) {
timestamp = Long.toString(System.currentTimeMillis());
} else {
// if we are here, the defaultTimestamp is not
// TimestampFieldMapper.Defaults.DEFAULT_TIMESTAMP but
// this can only happen if defaultTimestamp was
// assigned again because mappingMd and
// mappingMd#timestamp() are not null
assert mappingMd != null;
timestamp = MappingMetaData.Timestamp.parseStringTimestamp(defaultTimestamp, mappingMd.timestamp().dateTimeFormatter(), getVersion(metaData, concreteIndex));
}
}