diff --git a/lucene/core/src/java/org/apache/lucene/codecs/pfor/ForPostingsFormat.java b/lucene/core/src/java/org/apache/lucene/codecs/pfor/ForPostingsFormat.java index cfd90aa6453..ed7c63b48e7 100644 --- a/lucene/core/src/java/org/apache/lucene/codecs/pfor/ForPostingsFormat.java +++ b/lucene/core/src/java/org/apache/lucene/codecs/pfor/ForPostingsFormat.java @@ -17,27 +17,28 @@ package org.apache.lucene.codecs.pfor; * limitations under the License. */ -import java.util.Set; import java.io.IOException; +import java.util.Set; -import org.apache.lucene.util.BytesRef; -import org.apache.lucene.store.IOContext; -import org.apache.lucene.index.SegmentInfo; -import org.apache.lucene.index.SegmentWriteState; -import org.apache.lucene.index.SegmentReadState; +import org.apache.lucene.codecs.BlockTreeTermsReader; +import org.apache.lucene.codecs.BlockTreeTermsWriter; import org.apache.lucene.codecs.FieldsConsumer; import org.apache.lucene.codecs.FieldsProducer; -import org.apache.lucene.codecs.BlockTreeTermsWriter; -import org.apache.lucene.codecs.BlockTreeTermsReader; -import org.apache.lucene.codecs.TermsIndexReaderBase; -import org.apache.lucene.codecs.TermsIndexWriterBase; import org.apache.lucene.codecs.FixedGapTermsIndexReader; import org.apache.lucene.codecs.FixedGapTermsIndexWriter; import org.apache.lucene.codecs.PostingsFormat; -import org.apache.lucene.codecs.PostingsWriterBase; import org.apache.lucene.codecs.PostingsReaderBase; +import org.apache.lucene.codecs.PostingsWriterBase; +import org.apache.lucene.codecs.TermsIndexReaderBase; +import org.apache.lucene.codecs.TermsIndexWriterBase; import org.apache.lucene.codecs.sep.SepPostingsReader; import org.apache.lucene.codecs.sep.SepPostingsWriter; +import org.apache.lucene.index.SegmentInfo; +import org.apache.lucene.index.SegmentReadState; +import org.apache.lucene.index.SegmentWriteState; +import org.apache.lucene.store.IOContext; +import org.apache.lucene.util.BytesRef; +import org.apache.lucene.util.IOUtils; /** * Pass ForFactory to a PostingsWriter/ReaderBase, and get @@ -84,7 +85,7 @@ public final class ForPostingsFormat extends PostingsFormat { return ret; } finally { if (!success) { - postingsWriter.close(); + IOUtils.closeWhileHandlingException(postingsWriter); } } } @@ -111,7 +112,7 @@ public final class ForPostingsFormat extends PostingsFormat { return ret; } finally { if (!success) { - postingsReader.close(); + IOUtils.closeWhileHandlingException(postingsReader); } } } diff --git a/lucene/core/src/java/org/apache/lucene/codecs/pfor/PForPostingsFormat.java b/lucene/core/src/java/org/apache/lucene/codecs/pfor/PForPostingsFormat.java index 971ec06f638..b888ad6ebc4 100644 --- a/lucene/core/src/java/org/apache/lucene/codecs/pfor/PForPostingsFormat.java +++ b/lucene/core/src/java/org/apache/lucene/codecs/pfor/PForPostingsFormat.java @@ -17,27 +17,28 @@ package org.apache.lucene.codecs.pfor; * limitations under the License. */ -import java.util.Set; import java.io.IOException; +import java.util.Set; -import org.apache.lucene.util.BytesRef; -import org.apache.lucene.store.IOContext; -import org.apache.lucene.index.SegmentInfo; -import org.apache.lucene.index.SegmentWriteState; -import org.apache.lucene.index.SegmentReadState; +import org.apache.lucene.codecs.BlockTreeTermsReader; +import org.apache.lucene.codecs.BlockTreeTermsWriter; import org.apache.lucene.codecs.FieldsConsumer; import org.apache.lucene.codecs.FieldsProducer; -import org.apache.lucene.codecs.BlockTreeTermsWriter; -import org.apache.lucene.codecs.BlockTreeTermsReader; -import org.apache.lucene.codecs.TermsIndexReaderBase; -import org.apache.lucene.codecs.TermsIndexWriterBase; import org.apache.lucene.codecs.FixedGapTermsIndexReader; import org.apache.lucene.codecs.FixedGapTermsIndexWriter; import org.apache.lucene.codecs.PostingsFormat; -import org.apache.lucene.codecs.PostingsWriterBase; import org.apache.lucene.codecs.PostingsReaderBase; +import org.apache.lucene.codecs.PostingsWriterBase; +import org.apache.lucene.codecs.TermsIndexReaderBase; +import org.apache.lucene.codecs.TermsIndexWriterBase; import org.apache.lucene.codecs.sep.SepPostingsReader; import org.apache.lucene.codecs.sep.SepPostingsWriter; +import org.apache.lucene.index.SegmentInfo; +import org.apache.lucene.index.SegmentReadState; +import org.apache.lucene.index.SegmentWriteState; +import org.apache.lucene.store.IOContext; +import org.apache.lucene.util.BytesRef; +import org.apache.lucene.util.IOUtils; /** * Pass PForFactory to a PostingsWriter/ReaderBase, and get @@ -83,7 +84,7 @@ public final class PForPostingsFormat extends PostingsFormat { return ret; } finally { if (!success) { - postingsWriter.close(); + IOUtils.closeWhileHandlingException(postingsWriter); } } } @@ -110,7 +111,7 @@ public final class PForPostingsFormat extends PostingsFormat { return ret; } finally { if (!success) { - postingsReader.close(); + IOUtils.closeWhileHandlingException(postingsReader); } } }