Skip to content

Commit

Permalink
Simplify FrozenEngine#getReader (#39539)
Browse files Browse the repository at this point in the history
We really don’t need a try/finally in this method.
  • Loading branch information
dnhatn committed Mar 6, 2019
1 parent 7da62d3 commit 3591da6
Showing 1 changed file with 4 additions and 13 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -186,20 +186,11 @@ private synchronized DirectoryReader getOrOpenReader() throws IOException {
}

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

@Override
Expand Down

0 comments on commit 3591da6

Please sign in to comment.