Apache Lucene open-source search software
LUCENE-1251: be sure to close the descriptor even if super.close() hits an exception, in FSIndexOutput.close
Michael McCandless09b3a56ae2ec
diff --git a/src/java/org/apache/lucene/store/FSDirectory.java b/src/java/org/apache/lucene/store/FSDirectory.javaindex dc44c2020ae..124dab80d99 100644--- a/src/java/org/apache/lucene/store/FSDirectory.java+++ b/src/java/org/apache/lucene/store/FSDirectory.java@@ -634,9 +634,21 @@ public class FSDirectory extends Directory {public void close() throws IOException {// only close the file if it has not been closed yetif (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();+ }}}