lucene-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From rm...@apache.org
Subject svn commit: r1583565 - /lucene/dev/trunk/lucene/codecs/src/java/org/apache/lucene/codecs/memory/MemoryPostingsFormat.java
Date Tue, 01 Apr 2014 08:21:58 GMT
Author: rmuir
Date: Tue Apr  1 08:21:57 2014
New Revision: 1583565

URL: http://svn.apache.org/r1583565
Log:
LUCENE-2446: ensure we close file if we hit exception writing codec header

Modified:
    lucene/dev/trunk/lucene/codecs/src/java/org/apache/lucene/codecs/memory/MemoryPostingsFormat.java

Modified: lucene/dev/trunk/lucene/codecs/src/java/org/apache/lucene/codecs/memory/MemoryPostingsFormat.java
URL: http://svn.apache.org/viewvc/lucene/dev/trunk/lucene/codecs/src/java/org/apache/lucene/codecs/memory/MemoryPostingsFormat.java?rev=1583565&r1=1583564&r2=1583565&view=diff
==============================================================================
--- lucene/dev/trunk/lucene/codecs/src/java/org/apache/lucene/codecs/memory/MemoryPostingsFormat.java
(original)
+++ lucene/dev/trunk/lucene/codecs/src/java/org/apache/lucene/codecs/memory/MemoryPostingsFormat.java
Tue Apr  1 08:21:57 2014
@@ -284,7 +284,15 @@ public final class MemoryPostingsFormat 
     private MemoryFieldsConsumer(SegmentWriteState state) throws IOException {
       final String fileName = IndexFileNames.segmentFileName(state.segmentInfo.name, state.segmentSuffix,
EXTENSION);
       out = state.directory.createOutput(fileName, state.context);
-      CodecUtil.writeHeader(out, CODEC_NAME, VERSION_CURRENT);
+      boolean success = false;
+      try {
+        CodecUtil.writeHeader(out, CODEC_NAME, VERSION_CURRENT);
+        success = true;
+      } finally {
+        if (!success) {
+          IOUtils.closeWhileHandlingException(out);
+        }
+      }
       this.state = state;
     }
 



Mime
View raw message