mirror of https://github.com/apache/lucene.git
make IndexSearcher implement Closeable for consistency & IOUtils
git-svn-id: https://svn.apache.org/repos/asf/lucene/dev/trunk@1147162 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
parent
ee46aba2c0
commit
0d735dcd5a
|
@ -17,6 +17,7 @@ package org.apache.lucene.search;
|
|||
* limitations under the License.
|
||||
*/
|
||||
|
||||
import java.io.Closeable;
|
||||
import java.io.IOException;
|
||||
import java.util.Iterator;
|
||||
import java.util.NoSuchElementException;
|
||||
|
@ -67,7 +68,7 @@ import org.apache.lucene.util.ThreadInterruptedException;
|
|||
* synchronize on the <code>IndexSearcher</code> instance;
|
||||
* use your own (non-Lucene) objects instead.</p>
|
||||
*/
|
||||
public class IndexSearcher {
|
||||
public class IndexSearcher implements Closeable {
|
||||
final IndexReader reader; // package private for testing!
|
||||
private boolean closeReader;
|
||||
|
||||
|
@ -265,6 +266,7 @@ public class IndexSearcher {
|
|||
* If the IndexReader was supplied implicitly by specifying a directory, then
|
||||
* the IndexReader is closed.
|
||||
*/
|
||||
@Override
|
||||
public void close() throws IOException {
|
||||
if (closeReader) {
|
||||
reader.close();
|
||||
|
|
Loading…
Reference in New Issue