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 2011/06/28 11:39:13 UTC

svn commit: r1140498 - in /lucene/dev/trunk/lucene: CHANGES.txt src/java/org/apache/lucene/store/Directory.java

Author: simonw
Date: Tue Jun 28 09:39:13 2011
New Revision: 1140498

URL: http://svn.apache.org/viewvc?rev=1140498&view=rev
Log:
LUCENE-3251: Directory#copy leaks file handles

Modified:
    lucene/dev/trunk/lucene/CHANGES.txt
    lucene/dev/trunk/lucene/src/java/org/apache/lucene/store/Directory.java

Modified: lucene/dev/trunk/lucene/CHANGES.txt
URL: http://svn.apache.org/viewvc/lucene/dev/trunk/lucene/CHANGES.txt?rev=1140498&r1=1140497&r2=1140498&view=diff
==============================================================================
--- lucene/dev/trunk/lucene/CHANGES.txt (original)
+++ lucene/dev/trunk/lucene/CHANGES.txt Tue Jun 28 09:39:13 2011
@@ -484,6 +484,11 @@ Bug fixes
 
 ======================= Lucene 3.x (not yet released) ================
 
+Bug fixes
+
+* LUCENE-3251: Directory#copy failed to close target output if opening the
+  source stream failed. (Simon Willnauer)
+
 Optimizations
 
 * LUCENE-3201, LUCENE-3218: CompoundFileSystem code has been consolidated 

Modified: lucene/dev/trunk/lucene/src/java/org/apache/lucene/store/Directory.java
URL: http://svn.apache.org/viewvc/lucene/dev/trunk/lucene/src/java/org/apache/lucene/store/Directory.java?rev=1140498&r1=1140497&r2=1140498&view=diff
==============================================================================
--- lucene/dev/trunk/lucene/src/java/org/apache/lucene/store/Directory.java (original)
+++ lucene/dev/trunk/lucene/src/java/org/apache/lucene/store/Directory.java Tue Jun 28 09:39:13 2011
@@ -224,10 +224,12 @@ public abstract class Directory implemen
    * overwrite it if it does.
    */
   public void copy(Directory to, String src, String dest) throws IOException {
-    IndexOutput os = to.createOutput(dest);
-    IndexInput is = openInput(src);
+    IndexOutput os = null;
+    IndexInput is = null;
     IOException priorException = null;
     try {
+      os = to.createOutput(dest);
+      is = openInput(src);
       is.copyBytes(os, is.length());
     } catch (IOException ioe) {
       priorException = ioe;