diff --git a/lucene/test-framework/src/java/org/apache/lucene/codecs/asserting/AssertingTermVectorsFormat.java b/lucene/test-framework/src/java/org/apache/lucene/codecs/asserting/AssertingTermVectorsFormat.java index 257dee17ae2..7bdf85b7194 100644 --- a/lucene/test-framework/src/java/org/apache/lucene/codecs/asserting/AssertingTermVectorsFormat.java +++ b/lucene/test-framework/src/java/org/apache/lucene/codecs/asserting/AssertingTermVectorsFormat.java @@ -80,7 +80,7 @@ public class AssertingTermVectorsFormat extends TermVectorsFormat { static class AssertingTermVectorsWriter extends TermVectorsWriter { private final TermVectorsWriter in; private Status docStatus, fieldStatus, termStatus; - private int fieldCount, termCount, positionCount; + private int docCount, fieldCount, termCount, positionCount; boolean hasPositions; AssertingTermVectorsWriter(TermVectorsWriter in) { @@ -98,6 +98,7 @@ public class AssertingTermVectorsFormat extends TermVectorsFormat { in.startDocument(numVectorFields); docStatus = Status.STARTED; fieldCount = numVectorFields; + docCount++; } @Override @@ -167,6 +168,7 @@ public class AssertingTermVectorsFormat extends TermVectorsFormat { @Override public void finish(FieldInfos fis, int numDocs) throws IOException { + assert docCount == numDocs; assert docStatus == (numDocs > 0 ? Status.FINISHED : Status.UNDEFINED); assert fieldStatus != Status.STARTED; assert termStatus != Status.STARTED; @@ -181,9 +183,6 @@ public class AssertingTermVectorsFormat extends TermVectorsFormat { @Override public void close() throws IOException { in.close(); - assert docStatus != Status.STARTED; - assert fieldStatus != Status.STARTED; - assert termStatus != Status.STARTED; } }