Skip to content

Commit f0df5e6

Browse files
committed
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.
1 parent 61c5976 commit f0df5e6

File tree

1 file changed

+3
-1
lines changed

1 file changed

+3
-1
lines changed

core/src/test/java/org/elasticsearch/index/engine/InternalEngineTests.java

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1560,7 +1560,9 @@ private int assertOpsOnPrimary(List<Engine.Operation> ops, long currentOpVersion
15601560
if (randomBoolean()) {
15611561
// refresh and take the chance to check everything is ok so far
15621562
assertVisibleCount(engine, docDeleted ? 0 : 1);
1563-
if (docDeleted == false) {
1563+
// even if doc is not not deleted, lastFieldValue can still be null if this is the
1564+
// first op and it failed.
1565+
if (docDeleted == false && lastFieldValue != null) {
15641566
try (Searcher searcher = engine.acquireSearcher("test")) {
15651567
final TotalHitCountCollector collector = new TotalHitCountCollector();
15661568
searcher.searcher().search(new TermQuery(new Term("value", lastFieldValue)), collector);

0 commit comments

Comments
 (0)