diff --git a/src/java/org/apache/lucene/store/FSDirectory.java b/src/java/org/apache/lucene/store/FSDirectory.java index 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 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(); + } } }