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") @SuppressForbidden(reason = "we manage references explicitly here")
private synchronized DirectoryReader getReader() throws IOException { private synchronized DirectoryReader getReader() {
DirectoryReader reader = null; if (lastOpenedReader != null && lastOpenedReader.tryIncRef()) {
boolean success = false; return lastOpenedReader;
try {
if (lastOpenedReader != null && lastOpenedReader.tryIncRef()) {
reader = lastOpenedReader;
}
success = true;
return reader;
} finally {
if (success == false) {
IOUtils.close(reader);
}
} }
return null;
} }
@Override @Override