From 0a83273dfaae800132b277f9e7b1181d375d0117 Mon Sep 17 00:00:00 2001 From: Michael McCandless Date: Wed, 30 Apr 2014 17:12:54 +0000 Subject: [PATCH] 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 --- .../lucene/index/DefaultIndexingChain.java | 32 +++++++++---------- 1 file changed, 15 insertions(+), 17 deletions(-) diff --git a/lucene/core/src/java/org/apache/lucene/index/DefaultIndexingChain.java b/lucene/core/src/java/org/apache/lucene/index/DefaultIndexingChain.java index e0b2f83a1b4..f093901f9c6 100644 --- a/lucene/core/src/java/org/apache/lucene/index/DefaultIndexingChain.java +++ b/lucene/core/src/java/org/apache/lucene/index/DefaultIndexingChain.java @@ -23,10 +23,6 @@ import java.util.HashMap; import java.util.Map; 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.DocValuesFormat; import org.apache.lucene.codecs.FieldInfosWriter; @@ -265,21 +261,23 @@ final class DefaultIndexingChain extends DocConsumer { termsHash.startDocument(); // Invert indexed fields: - for (IndexableField field : docState.doc.indexableFields()) { - IndexableFieldType fieldType = field.fieldType(); - PerField fp = getOrAddField(field.name(), fieldType, true); - boolean first = fp.fieldGen != fieldGen; - fp.invert(field, first); + try { + for (IndexableField field : docState.doc.indexableFields()) { + IndexableFieldType fieldType = field.fieldType(); + PerField fp = getOrAddField(field.name(), fieldType, true); + boolean first = fp.fieldGen != fieldGen; + fp.invert(field, first); - if (first) { - fields[fieldCount++] = fp; - fp.fieldGen = fieldGen; + if (first) { + fields[fieldCount++] = fp; + fp.fieldGen = fieldGen; + } + } + } finally { + // Finish each field name seen in the document: + for (int i=0;i