mirror of https://github.com/apache/lucene.git
LUCENE-6616: Lucene50SegmentInfoFormat should not claim to have created a file until the createOutput in fact succeeded
git-svn-id: https://svn.apache.org/repos/asf/lucene/dev/trunk@1689942 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
parent
dd75010e6b
commit
3b0418c66e
|
@ -123,9 +123,10 @@ public class Lucene50SegmentInfoFormat extends SegmentInfoFormat {
|
|||
@Override
|
||||
public void write(Directory dir, SegmentInfo si, IOContext ioContext) throws IOException {
|
||||
final String fileName = IndexFileNames.segmentFileName(si.name, "", Lucene50SegmentInfoFormat.SI_EXTENSION);
|
||||
si.addFile(fileName);
|
||||
|
||||
try (IndexOutput output = dir.createOutput(fileName, ioContext)) {
|
||||
// Only add the file once we've successfully created it, else IFD assert can trip:
|
||||
si.addFile(fileName);
|
||||
CodecUtil.writeIndexHeader(output,
|
||||
Lucene50SegmentInfoFormat.CODEC_NAME,
|
||||
Lucene50SegmentInfoFormat.VERSION_CURRENT,
|
||||
|
|
|
@ -747,8 +747,8 @@ final class IndexFileDeleter implements Closeable {
|
|||
} catch (IOException e) { // if delete fails
|
||||
|
||||
// IndexWriter should only ask us to delete files it knows it wrote, so if we hit this, something is wrong!
|
||||
assert e instanceof NoSuchFileException == false: "file=" + fileName;
|
||||
assert e instanceof FileNotFoundException == false: "file=" + fileName;
|
||||
assert e instanceof NoSuchFileException == false: "hit unexpected NoSuchFileException: file=" + fileName;
|
||||
assert e instanceof FileNotFoundException == false: "hit unexpected FileNotFoundException: file=" + fileName;
|
||||
|
||||
// Some operating systems (e.g. Windows) don't
|
||||
// permit a file to be deleted while it is opened
|
||||
|
|
Loading…
Reference in New Issue