mirror of https://github.com/apache/lucene.git
handle Throwable not just IOE when closing
git-svn-id: https://svn.apache.org/repos/asf/lucene/dev/branches/slowclosing@1393535 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
parent
bbbe0a62ef
commit
a97703f1df
|
@ -334,13 +334,13 @@ final class StandardDirectoryReader extends DirectoryReader {
|
|||
|
||||
@Override
|
||||
protected void doClose() throws IOException {
|
||||
IOException ioe = null;
|
||||
Throwable firstExc = null;
|
||||
for (final AtomicReader r : getSequentialSubReaders()) {
|
||||
// try to close each reader, even if an exception is thrown
|
||||
try {
|
||||
r.decRef();
|
||||
} catch (IOException e) {
|
||||
if (ioe == null) ioe = e;
|
||||
} catch (Throwable t) {
|
||||
if (t == null) firstExc = t;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -351,7 +351,12 @@ final class StandardDirectoryReader extends DirectoryReader {
|
|||
}
|
||||
|
||||
// throw the first exception
|
||||
if (ioe != null) throw ioe;
|
||||
if (firstExc != null) {
|
||||
if (firstExc instanceof IOException) throw (IOException) firstExc;
|
||||
if (firstExc instanceof RuntimeException) throw (RuntimeException) firstExc;
|
||||
if (firstExc instanceof Error) throw (Error) firstExc;
|
||||
throw new RuntimeException(firstExc);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
Loading…
Reference in New Issue