Simplify FrozenEngine#getReader (#39539)

We really don’t need a try/finally in this method.
This commit is contained in:
Nhat Nguyen 2019-03-05 10:11:18 -05:00
parent 7da62d3b79
commit 3591da6ff8
1 changed files with 4 additions and 13 deletions

View File

@ -186,20 +186,11 @@ public final class FrozenEngine extends ReadOnlyEngine {
}
@SuppressForbidden(reason = "we manage references explicitly here")
private synchronized DirectoryReader getReader() throws IOException {
DirectoryReader reader = null;
boolean success = false;
try {
private synchronized DirectoryReader getReader() {
if (lastOpenedReader != null && lastOpenedReader.tryIncRef()) {
reader = lastOpenedReader;
}
success = true;
return reader;
} finally {
if (success == false) {
IOUtils.close(reader);
}
return lastOpenedReader;
}
return null;
}
@Override