LUCENE-5611: always call PerField.finish even on non-aborting exc

git-svn-id: https://svn.apache.org/repos/asf/lucene/dev/trunk@1591399 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
Michael McCandless 2014-04-30 17:12:54 +00:00
parent bc0d7bbb25
commit 0a83273dfa
1 changed files with 15 additions and 17 deletions

View File

@ -23,10 +23,6 @@ import java.util.HashMap;
import java.util.Map; import java.util.Map;
import org.apache.lucene.analysis.TokenStream; import org.apache.lucene.analysis.TokenStream;
import org.apache.lucene.analysis.tokenattributes.OffsetAttribute;
import org.apache.lucene.analysis.tokenattributes.PayloadAttribute;
import org.apache.lucene.analysis.tokenattributes.PositionIncrementAttribute;
import org.apache.lucene.analysis.tokenattributes.TermToBytesRefAttribute;
import org.apache.lucene.codecs.DocValuesConsumer; import org.apache.lucene.codecs.DocValuesConsumer;
import org.apache.lucene.codecs.DocValuesFormat; import org.apache.lucene.codecs.DocValuesFormat;
import org.apache.lucene.codecs.FieldInfosWriter; import org.apache.lucene.codecs.FieldInfosWriter;
@ -265,21 +261,23 @@ final class DefaultIndexingChain extends DocConsumer {
termsHash.startDocument(); termsHash.startDocument();
// Invert indexed fields: // Invert indexed fields:
for (IndexableField field : docState.doc.indexableFields()) { try {
IndexableFieldType fieldType = field.fieldType(); for (IndexableField field : docState.doc.indexableFields()) {
PerField fp = getOrAddField(field.name(), fieldType, true); IndexableFieldType fieldType = field.fieldType();
boolean first = fp.fieldGen != fieldGen; PerField fp = getOrAddField(field.name(), fieldType, true);
fp.invert(field, first); boolean first = fp.fieldGen != fieldGen;
fp.invert(field, first);
if (first) { if (first) {
fields[fieldCount++] = fp; fields[fieldCount++] = fp;
fp.fieldGen = fieldGen; fp.fieldGen = fieldGen;
}
}
} finally {
// Finish each field name seen in the document:
for (int i=0;i<fieldCount;i++) {
fields[i].finish();
} }
}
// Finish each field name seen in the document:
for (int i=0;i<fieldCount;i++) {
fields[i].finish();
} }
boolean success = false; boolean success = false;