lucene-java-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From mikemcc...@apache.org
Subject svn commit: r642341 - /lucene/java/branches/lucene_2_3/src/java/org/apache/lucene/store/FSDirectory.java
Date Fri, 28 Mar 2008 19:24:11 GMT
Author: mikemccand
Date: Fri Mar 28 12:24:06 2008
New Revision: 642341

URL: http://svn.apache.org/viewvc?rev=642341&view=rev
Log:
LUCENE-1251: be sure to close the descriptor even if super.close() hits an exception, in FSIndexOutput.close

Modified:
    lucene/java/branches/lucene_2_3/src/java/org/apache/lucene/store/FSDirectory.java

Modified: lucene/java/branches/lucene_2_3/src/java/org/apache/lucene/store/FSDirectory.java
URL: http://svn.apache.org/viewvc/lucene/java/branches/lucene_2_3/src/java/org/apache/lucene/store/FSDirectory.java?rev=642341&r1=642340&r2=642341&view=diff
==============================================================================
--- lucene/java/branches/lucene_2_3/src/java/org/apache/lucene/store/FSDirectory.java (original)
+++ lucene/java/branches/lucene_2_3/src/java/org/apache/lucene/store/FSDirectory.java Fri
Mar 28 12:24:06 2008
@@ -601,9 +601,21 @@
     public void close() throws IOException {
       // only close the file if it has not been closed yet
       if (isOpen) {
-        super.close();
-        file.close();
-        isOpen = false;
+        boolean success = false;
+        try {
+          super.close();
+          success = true;
+        } finally {
+          isOpen = false;
+          if (!success) {
+            try {
+              file.close();
+            } catch (Throwable t) {
+              // Suppress so we don't mask original exception
+            }
+          } else
+            file.close();
+        }
       }
     }
   



Mime
View raw message