InternalEngineTests: fix a potential NPE in assertOpsOnPrimary

assertOpsOnPrimary may inherit a situation where the document exist but it doesn't the last indexed value.
This cloud cause an NPE.
This commit is contained in:
Boaz Leskes 2017-04-09 21:21:00 +02:00
parent 61c5976aee
commit f0df5e64d8

View File

@ -1560,7 +1560,9 @@ public class InternalEngineTests extends ESTestCase {
if (randomBoolean()) {
// refresh and take the chance to check everything is ok so far
assertVisibleCount(engine, docDeleted ? 0 : 1);
if (docDeleted == false) {
// even if doc is not not deleted, lastFieldValue can still be null if this is the
// first op and it failed.
if (docDeleted == false && lastFieldValue != null) {
try (Searcher searcher = engine.acquireSearcher("test")) {
final TotalHitCountCollector collector = new TotalHitCountCollector();
searcher.searcher().search(new TermQuery(new Term("value", lastFieldValue)), collector);