You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@lucene.apache.org by si...@apache.org on 2012/05/19 18:29:58 UTC

svn commit: r1340514 - /lucene/dev/trunk/lucene/core/src/java/org/apache/lucene/store/CompoundFileWriter.java

Author: simonw
Date: Sat May 19 16:29:58 2012
New Revision: 1340514

URL: http://svn.apache.org/viewvc?rev=1340514&view=rev
Log:
LUCENE-4070: assign output to member to prevent double opening on error

Modified:
    lucene/dev/trunk/lucene/core/src/java/org/apache/lucene/store/CompoundFileWriter.java

Modified: lucene/dev/trunk/lucene/core/src/java/org/apache/lucene/store/CompoundFileWriter.java
URL: http://svn.apache.org/viewvc/lucene/dev/trunk/lucene/core/src/java/org/apache/lucene/store/CompoundFileWriter.java?rev=1340514&r1=1340513&r2=1340514&view=diff
==============================================================================
--- lucene/dev/trunk/lucene/core/src/java/org/apache/lucene/store/CompoundFileWriter.java (original)
+++ lucene/dev/trunk/lucene/core/src/java/org/apache/lucene/store/CompoundFileWriter.java Sat May 19 16:29:58 2012
@@ -118,16 +118,14 @@ final class CompoundFileWriter implement
   
   private synchronized IndexOutput getOutput() throws IOException {
     if (dataOut == null) {
-      IndexOutput dataOutput = null;
       boolean success = false;
       try {
-        dataOutput = directory.createOutput(dataFileName, IOContext.DEFAULT);
-        dataOutput.writeVInt(FORMAT_CURRENT);
-        dataOut = dataOutput;
+        dataOut = directory.createOutput(dataFileName, IOContext.DEFAULT);
+        dataOut.writeVInt(FORMAT_CURRENT);
         success = true;
       } finally {
         if (!success) {
-          IOUtils.closeWhileHandlingException(dataOutput);
+          IOUtils.closeWhileHandlingException(dataOut);
         }
       }
     }