Apache Lucene open-source search software
LUCENE-2881: fix intermittent failing test by clearing term vectors bits in FieldInfos for segments that had only docs with non-aborting exceptions
Michael Busch7fc46ffab148
diff --git a/lucene/src/java/org/apache/lucene/index/DocFieldProcessor.java b/lucene/src/java/org/apache/lucene/index/DocFieldProcessor.javaindex 6416f518983..3a85224462b 100644--- a/lucene/src/java/org/apache/lucene/index/DocFieldProcessor.java+++ b/lucene/src/java/org/apache/lucene/index/DocFieldProcessor.java@@ -59,6 +59,13 @@ final class DocFieldProcessor extends DocConsumer {// FreqProxTermsWriter does this with// FieldInfo.storePayload.final String fileName = IndexFileNames.segmentFileName(state.segmentName, "", IndexFileNames.FIELD_INFOS_EXTENSION);++ // If this segment only has docs that hit non-aborting exceptions,+ // then no term vectors files will have been written; therefore we+ // need to update the fieldInfos and clear the term vectors bits+ if (!state.hasVectors) {+ state.fieldInfos.clearVectors();+ }state.fieldInfos.write(state.directory, fileName);}diff --git a/lucene/src/java/org/apache/lucene/index/FieldInfos.java b/lucene/src/java/org/apache/lucene/index/FieldInfos.javaindex d5834bc5cbf..a3417798b20 100644--- a/lucene/src/java/org/apache/lucene/index/FieldInfos.java+++ b/lucene/src/java/org/apache/lucene/index/FieldInfos.java@@ -403,6 +403,14 @@ public final class FieldInfos implements Iterable<FieldInfo> {return false;}+ void clearVectors() {+ for (FieldInfo fi : this) {+ fi.storeTermVector = false;+ fi.storeOffsetWithTermVector = false;+ fi.storePositionWithTermVector = false;+ }+ }+public boolean hasNorms() {for (FieldInfo fi : this) {if (!fi.omitNorms) {