mirror of https://github.com/apache/lucene.git
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:
parent
828333ab52
commit
09b3a56ae2
|
@ -634,9 +634,21 @@ public class FSDirectory extends Directory {
|
||||||
public void close() throws IOException {
|
public void close() throws IOException {
|
||||||
// only close the file if it has not been closed yet
|
// only close the file if it has not been closed yet
|
||||||
if (isOpen) {
|
if (isOpen) {
|
||||||
super.close();
|
boolean success = false;
|
||||||
file.close();
|
try {
|
||||||
isOpen = false;
|
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();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue