LUCENE-1251: be sure to close the descriptor even if super.close() hits an exception, in FSIndexOutput.close

git-svn-id: https://svn.apache.org/repos/asf/lucene/java/trunk@642339 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
Michael McCandless 2008-03-28 19:10:58 +00:00
parent 828333ab52
commit 09b3a56ae2
1 changed files with 15 additions and 3 deletions

View File

@ -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) {
boolean success = false;
try {
super.close();
file.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();
}
}
}