From 1498d5b0b79531cb9a9105062d3c70baa99c6593 Mon Sep 17 00:00:00 2001 From: Michael McCandless Date: Tue, 14 Jul 2015 14:50:19 +0000 Subject: [PATCH] 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 --- .../lucene/codecs/simpletext/SimpleTextSegmentInfoFormat.java | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/lucene/codecs/src/java/org/apache/lucene/codecs/simpletext/SimpleTextSegmentInfoFormat.java b/lucene/codecs/src/java/org/apache/lucene/codecs/simpletext/SimpleTextSegmentInfoFormat.java index 4b0e023b4e2..bbdc80e3fb5 100644 --- a/lucene/codecs/src/java/org/apache/lucene/codecs/simpletext/SimpleTextSegmentInfoFormat.java +++ b/lucene/codecs/src/java/org/apache/lucene/codecs/simpletext/SimpleTextSegmentInfoFormat.java @@ -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);