diff --git a/lucene/src/java/org/apache/lucene/search/IndexSearcher.java b/lucene/src/java/org/apache/lucene/search/IndexSearcher.java index 81b90f28679..a50d7713978 100644 --- a/lucene/src/java/org/apache/lucene/search/IndexSearcher.java +++ b/lucene/src/java/org/apache/lucene/search/IndexSearcher.java @@ -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 IndexSearcher instance; * use your own (non-Lucene) objects instead.

*/ -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();