LUCENE-3476: small code cleanup (use one try/finally/success)

git-svn-id: https://svn.apache.org/repos/asf/lucene/dev/trunk@1177995 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
Michael McCandless 2011-10-01 14:39:37 +00:00
parent d607980a5a
commit 52e8d40c2f
1 changed files with 4 additions and 11 deletions

View File

@ -25,6 +25,7 @@ import java.util.concurrent.Semaphore;
import org.apache.lucene.index.IndexReader;
import org.apache.lucene.index.IndexWriter;
import org.apache.lucene.index.NRTManager; // javadocs
import org.apache.lucene.search.IndexSearcher; // javadocs
import org.apache.lucene.store.AlreadyClosedException;
import org.apache.lucene.store.Directory;
@ -141,19 +142,11 @@ public class SearcherManager implements Closeable {
IndexReader newReader = currentSearcher.getIndexReader().reopen();
if (newReader != currentSearcher.getIndexReader()) {
IndexSearcher newSearcher = new IndexSearcher(newReader, es);
if (warmer != null) {
boolean success = false;
try {
warmer.warm(newSearcher);
success = true;
} finally {
if (!success) {
newReader.decRef();
}
}
}
boolean success = false;
try {
if (warmer != null) {
warmer.warm(newSearcher);
}
swapSearcher(newSearcher);
success = true;
} finally {