mirror of https://github.com/apache/lucene.git
throw ACE not NPE if you close while maybeReopen runs
git-svn-id: https://svn.apache.org/repos/asf/lucene/dev/trunk@1208525 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
parent
a1aefefdd9
commit
6f6a6c2b09
|
@ -159,7 +159,13 @@ public final class SearcherManager {
|
|||
try {
|
||||
// IR.openIfChanged preserves NRT and applyDeletes
|
||||
// in the newly returned reader:
|
||||
final IndexReader newReader = IndexReader.openIfChanged(currentSearcher.getIndexReader());
|
||||
final IndexReader newReader;
|
||||
final IndexSearcher searcherToReopen = acquire();
|
||||
try {
|
||||
newReader = IndexReader.openIfChanged(searcherToReopen.getIndexReader());
|
||||
} finally {
|
||||
release(searcherToReopen);
|
||||
}
|
||||
if (newReader != null) {
|
||||
final IndexSearcher newSearcher = new IndexSearcher(newReader, es);
|
||||
boolean success = false;
|
||||
|
@ -246,6 +252,10 @@ public final class SearcherManager {
|
|||
|
||||
private synchronized void swapSearcher(IndexSearcher newSearcher) throws IOException {
|
||||
ensureOpen();
|
||||
// Don't allow un-closing!
|
||||
if (currentSearcher == null && newSearcher != null) {
|
||||
throw new AlreadyClosedException("this SearcherManager is closed");
|
||||
}
|
||||
final IndexSearcher oldSearcher = currentSearcher;
|
||||
currentSearcher = newSearcher;
|
||||
release(oldSearcher);
|
||||
|
|
|
@ -237,9 +237,7 @@ public class TestSearcherManager extends ThreadedIndexingAndSearchingTestCase {
|
|||
});
|
||||
thread.start();
|
||||
awaitEnterWarm.await();
|
||||
for (int i = 0; i < 2; i++) {
|
||||
searcherManager.close();
|
||||
}
|
||||
searcherManager.close();
|
||||
awaitClose.countDown();
|
||||
thread.join();
|
||||
try {
|
||||
|
|
Loading…
Reference in New Issue