lucene-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From mikemcc...@apache.org
Subject svn commit: r1208525 - in /lucene/dev/trunk/lucene/src: java/org/apache/lucene/search/SearcherManager.java test/org/apache/lucene/search/TestSearcherManager.java
Date Wed, 30 Nov 2011 17:14:20 GMT
Author: mikemccand
Date: Wed Nov 30 17:14:19 2011
New Revision: 1208525

URL: http://svn.apache.org/viewvc?rev=1208525&view=rev
Log:
throw ACE not NPE if you close while maybeReopen runs

Modified:
    lucene/dev/trunk/lucene/src/java/org/apache/lucene/search/SearcherManager.java
    lucene/dev/trunk/lucene/src/test/org/apache/lucene/search/TestSearcherManager.java

Modified: lucene/dev/trunk/lucene/src/java/org/apache/lucene/search/SearcherManager.java
URL: http://svn.apache.org/viewvc/lucene/dev/trunk/lucene/src/java/org/apache/lucene/search/SearcherManager.java?rev=1208525&r1=1208524&r2=1208525&view=diff
==============================================================================
--- lucene/dev/trunk/lucene/src/java/org/apache/lucene/search/SearcherManager.java (original)
+++ lucene/dev/trunk/lucene/src/java/org/apache/lucene/search/SearcherManager.java Wed Nov
30 17:14:19 2011
@@ -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);

Modified: lucene/dev/trunk/lucene/src/test/org/apache/lucene/search/TestSearcherManager.java
URL: http://svn.apache.org/viewvc/lucene/dev/trunk/lucene/src/test/org/apache/lucene/search/TestSearcherManager.java?rev=1208525&r1=1208524&r2=1208525&view=diff
==============================================================================
--- lucene/dev/trunk/lucene/src/test/org/apache/lucene/search/TestSearcherManager.java (original)
+++ lucene/dev/trunk/lucene/src/test/org/apache/lucene/search/TestSearcherManager.java Wed
Nov 30 17:14:19 2011
@@ -237,9 +237,7 @@ public class TestSearcherManager extends
     });
     thread.start();
     awaitEnterWarm.await();
-    for (int i = 0; i < 2; i++) {
-      searcherManager.close();
-    }
+    searcherManager.close();
     awaitClose.countDown();
     thread.join();
     try {



Mime
View raw message