You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@lucene.apache.org by mi...@apache.org on 2012/07/09 19:30:25 UTC

svn commit: r1359299 - in /lucene/dev/branches/pforcodec_3892/lucene/core/src/java/org/apache/lucene/codecs/pfor: ForFactory.java PForFactory.java

Author: mikemccand
Date: Mon Jul  9 17:30:25 2012
New Revision: 1359299

URL: http://svn.apache.org/viewvc?rev=1359299&view=rev
Log:
LUCENE-3892: close IndexOutput on exception

Modified:
    lucene/dev/branches/pforcodec_3892/lucene/core/src/java/org/apache/lucene/codecs/pfor/ForFactory.java
    lucene/dev/branches/pforcodec_3892/lucene/core/src/java/org/apache/lucene/codecs/pfor/PForFactory.java

Modified: lucene/dev/branches/pforcodec_3892/lucene/core/src/java/org/apache/lucene/codecs/pfor/ForFactory.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/pforcodec_3892/lucene/core/src/java/org/apache/lucene/codecs/pfor/ForFactory.java?rev=1359299&r1=1359298&r2=1359299&view=diff
==============================================================================
--- lucene/dev/branches/pforcodec_3892/lucene/core/src/java/org/apache/lucene/codecs/pfor/ForFactory.java (original)
+++ lucene/dev/branches/pforcodec_3892/lucene/core/src/java/org/apache/lucene/codecs/pfor/ForFactory.java Mon Jul  9 17:30:25 2012
@@ -45,7 +45,17 @@ public final class ForFactory extends In
 
   @Override
   public IntIndexOutput createOutput(Directory dir, String fileName, IOContext context)  throws IOException {
-    return new ForIndexOutput(dir.createOutput(fileName, context), blockSize);
+    boolean success = false;
+    IndexOutput out = dir.createOutput(fileName, context);
+    try {
+      IntIndexOutput ret = new ForIndexOutput(out, blockSize);
+      success = true;
+      return ret;
+    } finally {
+      if (!success) {
+        IOUtils.closeWhileHandlingException(out);
+      }
+    }
   }
 
   @Override

Modified: lucene/dev/branches/pforcodec_3892/lucene/core/src/java/org/apache/lucene/codecs/pfor/PForFactory.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/pforcodec_3892/lucene/core/src/java/org/apache/lucene/codecs/pfor/PForFactory.java?rev=1359299&r1=1359298&r2=1359299&view=diff
==============================================================================
--- lucene/dev/branches/pforcodec_3892/lucene/core/src/java/org/apache/lucene/codecs/pfor/PForFactory.java (original)
+++ lucene/dev/branches/pforcodec_3892/lucene/core/src/java/org/apache/lucene/codecs/pfor/PForFactory.java Mon Jul  9 17:30:25 2012
@@ -45,7 +45,17 @@ public final class PForFactory extends I
 
   @Override
   public IntIndexOutput createOutput(Directory dir, String fileName, IOContext context)  throws IOException {
-    return new PForIndexOutput(dir.createOutput(fileName, context), blockSize);
+    boolean success = false;
+    IndexOutput out = dir.createOutput(fileName, context);
+    try {
+      IntIndexOutput ret = new PForIndexOutput(out, blockSize);
+      success = true;
+      return ret;
+    } finally {
+      if (!success) {
+        IOUtils.closeWhileHandlingException(out);
+      }
+    }
   }
 
   @Override