From 05bfc5829457a4607a5828082bab18eefbc5a7b1 Mon Sep 17 00:00:00 2001 From: Michael Busch Date: Wed, 23 Feb 2011 07:29:02 +0000 Subject: [PATCH] fix silly bug that crept in during last trunk merge git-svn-id: https://svn.apache.org/repos/asf/lucene/dev/branches/realtime_search@1073625 13f79535-47bb-0310-9956-ffa450edef68 --- .../org/apache/lucene/index/IndexWriter.java | 91 +++++++++---------- 1 file changed, 45 insertions(+), 46 deletions(-) diff --git a/lucene/src/java/org/apache/lucene/index/IndexWriter.java b/lucene/src/java/org/apache/lucene/index/IndexWriter.java index 4f0148a9840..66bfb3ed039 100644 --- a/lucene/src/java/org/apache/lucene/index/IndexWriter.java +++ b/lucene/src/java/org/apache/lucene/index/IndexWriter.java @@ -2085,12 +2085,12 @@ public class IndexWriter implements Closeable { setDiagnostics(newSegment, "flush"); - if (useCompoundFile(newSegment)) { - String compoundFileName = IndexFileNames.segmentFileName(newSegment.name, "", IndexFileNames.COMPOUND_FILE_EXTENSION); - message("creating compound file " + compoundFileName); + boolean success = false; + try { + if (useCompoundFile(newSegment)) { + String compoundFileName = IndexFileNames.segmentFileName(newSegment.name, "", IndexFileNames.COMPOUND_FILE_EXTENSION); + message("creating compound file " + compoundFileName); // Now build compound file - boolean success = false; - try { CompoundFileWriter cfsWriter = new CompoundFileWriter(directory, compoundFileName); for(String fileName : newSegment.files()) { cfsWriter.addFile(fileName); @@ -2103,56 +2103,55 @@ public class IndexWriter implements Closeable { } newSegment.setUseCompoundFile(true); + } - // Must write deleted docs after the CFS so we don't - // slurp the del file into CFS: - if (deletedDocs != null) { - final int delCount = deletedDocs.count(); - assert delCount > 0; - newSegment.setDelCount(delCount); - newSegment.advanceDelGen(); - final String delFileName = newSegment.getDelFileName(); - if (infoStream != null) { - message("flush: write " + delCount + " deletes to " + delFileName); - } - boolean success2 = false; - try { - // TODO: in the NRT case it'd be better to hand - // this del vector over to the - // shortly-to-be-opened SegmentReader and let it - // carry the changes; there's no reason to use - // filesystem as intermediary here. - deletedDocs.write(directory, delFileName); - success2 = true; - } finally { - if (!success2) { - try { - directory.deleteFile(delFileName); - } catch (Throwable t) { - // suppress this so we keep throwing the - // original exception - } - } - } + // Must write deleted docs after the CFS so we don't + // slurp the del file into CFS: + if (deletedDocs != null) { + final int delCount = deletedDocs.count(); + assert delCount > 0; + newSegment.setDelCount(delCount); + newSegment.advanceDelGen(); + final String delFileName = newSegment.getDelFileName(); + if (infoStream != null) { + message("flush: write " + delCount + " deletes to " + delFileName); } - - success = true; - } finally { - if (!success) { - if (infoStream != null) { - message("hit exception " + - "reating compound file for newly flushed segment " + newSegment.name); - } - - synchronized(this) { - deleter.refresh(newSegment.name); + boolean success2 = false; + try { + // TODO: in the NRT case it'd be better to hand + // this del vector over to the + // shortly-to-be-opened SegmentReader and let it + // carry the changes; there's no reason to use + // filesystem as intermediary here. + deletedDocs.write(directory, delFileName); + success2 = true; + } finally { + if (!success2) { + try { + directory.deleteFile(delFileName); + } catch (Throwable t) { + // suppress this so we keep throwing the + // original exception + } } } } + success = true; + } finally { + if (!success) { + if (infoStream != null) { + message("hit exception " + + "reating compound file for newly flushed segment " + newSegment.name); + } + synchronized(this) { + deleter.refresh(newSegment.name); + } + } } + synchronized(this) { segmentInfos.add(newSegment); checkpoint();