LUCENE-3892: suppress exceptions from close() while we are already handling an exception

git-svn-id: https://svn.apache.org/repos/asf/lucene/dev/branches/pforcodec_3892@1360184 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
Michael McCandless 2012-07-11 14:17:20 +00:00
parent a227add782
commit 101ea65be9
2 changed files with 28 additions and 26 deletions

View File

@ -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);
}
}
}

View File

@ -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);
}
}
}