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:
Simon Willnauer 2011-07-15 14:21:11 +00:00
parent ee46aba2c0
commit 0d735dcd5a
1 changed files with 3 additions and 1 deletions

View File

@ -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();