LUCENE-6616: only claim to have created a file once createOutput succeeded

git-svn-id: https://svn.apache.org/repos/asf/lucene/dev/trunk@1690952 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
Michael McCandless 2015-07-14 14:50:19 +00:00
parent 422694f9c0
commit 1498d5b0b7
1 changed files with 2 additions and 1 deletions

View File

@ -154,9 +154,10 @@ public class SimpleTextSegmentInfoFormat extends SegmentInfoFormat {
public void write(Directory dir, SegmentInfo si, IOContext ioContext) throws IOException {
String segFileName = IndexFileNames.segmentFileName(si.name, "", SimpleTextSegmentInfoFormat.SI_EXTENSION);
si.addFile(segFileName);
try (IndexOutput output = dir.createOutput(segFileName, ioContext)) {
// Only add the file once we've successfully created it, else IFD assert can trip:
si.addFile(segFileName);
BytesRefBuilder scratch = new BytesRefBuilder();
SimpleTextUtil.write(output, SI_VERSION);