diff options
author | Boaz Leskes <b.leskes@gmail.com> | 2017-04-09 21:21:00 +0200 |
---|---|---|
committer | Boaz Leskes <b.leskes@gmail.com> | 2017-04-09 21:21:00 +0200 |
commit | f0df5e64d8172c200e9e5e5a8b93a08158e22be2 (patch) | |
tree | 9cc7ac8ae458fa2fd1d0d1eb3ee3a0f477046a31 | |
parent | 61c5976aee89f83fbbc181c4388c8360e8b35da0 (diff) |
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.
-rw-r--r-- | core/src/test/java/org/elasticsearch/index/engine/InternalEngineTests.java | 4 |
1 files changed, 3 insertions, 1 deletions
diff --git a/core/src/test/java/org/elasticsearch/index/engine/InternalEngineTests.java b/core/src/test/java/org/elasticsearch/index/engine/InternalEngineTests.java index 7e5d8d7e73..8840059706 100644 --- a/core/src/test/java/org/elasticsearch/index/engine/InternalEngineTests.java +++ b/core/src/test/java/org/elasticsearch/index/engine/InternalEngineTests.java @@ -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); |