From 3899e18ca3e9a3d06ea1c704357daec4ec7f3273 Mon Sep 17 00:00:00 2001
From: Robert Muir
Date: Mon, 12 Dec 2011 00:21:40 +0000
Subject: [PATCH] LUCENE-3640: Remove IndexSearcher.close
git-svn-id: https://svn.apache.org/repos/asf/lucene/dev/trunk@1213117 13f79535-47bb-0310-9956-ffa450edef68
---
lucene/CHANGES.txt | 4 +
.../org/apache/lucene/demo/SearchFiles.java | 1 -
.../highlight/HighlighterPhraseTest.java | 213 ++++++++----------
.../search/highlight/HighlighterTest.java | 5 -
.../search/highlight/TokenSourcesTest.java | 150 ++++++------
.../lucene/index/memory/MemoryIndexTest.java | 2 -
.../sandbox/queries/DuplicateFilterTest.java | 1 -
.../queries/FuzzyLikeThisQueryTest.java | 1 -
.../queries/TestSlowCollationMethods.java | 1 -
.../sandbox/queries/regex/TestRegexQuery.java | 1 -
.../queries/regex/TestSpanRegexQuery.java | 1 -
.../lucene/spatial/tier/TestCartesian.java | 4 -
.../apache/lucene/search/IndexSearcher.java | 8 +-
.../lucene/analysis/CollationTestBase.java | 4 -
.../ThreadedIndexingAndSearchingTestCase.java | 1 -
.../org/apache/lucene/search/CheckHits.java | 1 -
.../org/apache/lucene/search/QueryUtils.java | 7 -
.../apache/lucene/util/LuceneTestCase.java | 36 +--
.../src/test/org/apache/lucene/TestDemo.java | 1 -
.../org/apache/lucene/TestExternalCodecs.java | 2 -
.../test/org/apache/lucene/TestSearch.java | 1 -
.../lucene/TestSearchForDuplicates.java | 3 -
.../apache/lucene/document/TestDocument.java | 2 -
.../index/TestBackwardsCompatibility.java | 6 -
.../apache/lucene/index/TestBinaryTerms.java | 1 -
.../org/apache/lucene/index/TestCodecs.java | 1 -
.../index/TestCrashCausesCorruptIndex.java | 1 -
.../lucene/index/TestDeletionPolicy.java | 3 -
.../lucene/index/TestForTooMuchCloning.java | 1 -
.../lucene/index/TestIndexReaderReopen.java | 1 -
.../apache/lucene/index/TestIndexWriter.java | 6 -
.../lucene/index/TestIndexWriterCommit.java | 8 -
.../lucene/index/TestIndexWriterDelete.java | 2 -
.../index/TestIndexWriterOnDiskFull.java | 2 -
.../lucene/index/TestIndexWriterReader.java | 6 -
.../lucene/index/TestLazyProxSkipping.java | 2 -
.../apache/lucene/index/TestNRTThreads.java | 1 -
.../org/apache/lucene/index/TestOmitTf.java | 3 +-
.../lucene/index/TestParallelReader.java | 2 -
.../apache/lucene/index/TestReaderClosed.java | 1 -
.../lucene/index/TestStressIndexing.java | 1 -
.../apache/lucene/index/TestTermsEnum2.java | 1 -
.../lucene3x/TestTermInfosReaderIndex.java | 1 -
.../perfield/TestPerFieldPostingsFormat.java | 1 -
.../lucene/search/TestAutomatonQuery.java | 1 -
.../search/TestAutomatonQueryUnicode.java | 1 -
.../apache/lucene/search/TestBoolean2.java | 2 -
.../search/TestBooleanMinShouldMatch.java | 1 -
.../apache/lucene/search/TestBooleanOr.java | 1 -
.../lucene/search/TestBooleanQuery.java | 1 -
.../lucene/search/TestBooleanScorer.java | 3 -
.../search/TestCachingWrapperFilter.java | 4 -
.../lucene/search/TestConstantScoreQuery.java | 1 -
.../apache/lucene/search/TestDateFilter.java | 2 -
.../apache/lucene/search/TestDateSort.java | 1 -
.../search/TestDisjunctionMaxQuery.java | 1 -
.../apache/lucene/search/TestDocIdSet.java | 1 -
.../lucene/search/TestDocValuesScoring.java | 3 -
.../search/TestElevationComparator.java | 1 -
.../lucene/search/TestExplanations.java | 1 -
.../search/TestFieldCacheRangeFilter.java | 8 -
.../search/TestFieldCacheTermsFilter.java | 1 -
.../lucene/search/TestFieldValueFilter.java | 2 -
.../lucene/search/TestFilteredQuery.java | 1 -
.../lucene/search/TestFilteredSearch.java | 1 -
.../apache/lucene/search/TestFuzzyQuery.java | 7 -
.../apache/lucene/search/TestFuzzyQuery2.java | 1 -
.../lucene/search/TestMatchAllDocsQuery.java | 2 -
.../lucene/search/TestMultiPhraseQuery.java | 6 -
.../search/TestMultiTermConstantScore.java | 8 -
.../TestMultiValuedNumericRangeQuery.java | 1 -
.../org/apache/lucene/search/TestNot.java | 1 -
.../search/TestNumericRangeQuery32.java | 2 -
.../search/TestNumericRangeQuery64.java | 2 -
.../lucene/search/TestPhrasePrefixQuery.java | 1 -
.../apache/lucene/search/TestPhraseQuery.java | 6 -
.../lucene/search/TestPositionIncrement.java | 1 -
.../TestPositiveScoresOnlyCollector.java | 1 -
.../lucene/search/TestPrefixFilter.java | 1 -
.../search/TestPrefixInBooleanQuery.java | 1 -
.../apache/lucene/search/TestPrefixQuery.java | 1 -
.../lucene/search/TestPrefixRandom.java | 1 -
.../lucene/search/TestQueryWrapperFilter.java | 2 -
.../apache/lucene/search/TestRegexpQuery.java | 1 -
.../lucene/search/TestRegexpRandom.java | 1 -
.../lucene/search/TestRegexpRandom2.java | 2 -
.../TestScoreCachingWrappingScorer.java | 1 -
.../apache/lucene/search/TestScorerPerf.java | 1 -
.../apache/lucene/search/TestSearchAfter.java | 1 -
.../lucene/search/TestSearchWithThreads.java | 1 -
.../apache/lucene/search/TestSimilarity.java | 1 -
.../lucene/search/TestSimilarityProvider.java | 1 -
.../lucene/search/TestSloppyPhraseQuery.java | 4 -
.../org/apache/lucene/search/TestSort.java | 9 -
.../lucene/search/TestSubScorerFreqs.java | 1 -
.../lucene/search/TestTermRangeFilter.java | 4 -
.../lucene/search/TestTermRangeQuery.java | 14 --
.../apache/lucene/search/TestTermScorer.java | 1 -
.../apache/lucene/search/TestTermVectors.java | 1 -
.../search/TestTimeLimitingCollector.java | 1 -
.../lucene/search/TestTopDocsCollector.java | 1 -
.../lucene/search/TestTopDocsMerge.java | 1 -
.../search/TestTopScoreDocCollector.java | 1 -
.../apache/lucene/search/TestWildcard.java | 7 -
.../lucene/search/TestWildcardRandom.java | 1 -
.../search/payloads/TestPayloadNearQuery.java | 1 -
.../search/payloads/TestPayloadTermQuery.java | 2 -
.../search/similarities/TestSimilarity2.java | 7 -
.../similarities/TestSimilarityBase.java | 1 -
.../lucene/search/spans/TestBasics.java | 1 -
.../spans/TestFieldMaskingSpanQuery.java | 1 -
.../search/spans/TestNearSpansOrdered.java | 1 -
.../lucene/search/spans/TestPayloadSpans.java | 7 -
.../search/spans/TestSpanFirstQuery.java | 1 -
.../spans/TestSpanMultiTermQueryWrapper.java | 1 -
.../apache/lucene/search/spans/TestSpans.java | 2 -
.../search/spans/TestSpansAdvanced.java | 1 -
.../search/spans/TestSpansAdvanced2.java | 1 -
.../lucene/store/TestBufferedIndexInput.java | 2 -
.../apache/lucene/store/TestLockFactory.java | 1 -
.../apache/lucene/store/TestRAMDirectory.java | 1 -
.../apache/lucene/store/TestWindowsMMap.java | 1 -
.../analysis/core/TestKeywordAnalyzer.java | 1 -
.../shingle/ShingleAnalyzerWrapperTest.java | 1 -
.../lucene/benchmark/byTask/PerfRunData.java | 2 +-
.../benchmark/byTask/tasks/ReadTask.java | 1 -
.../benchmark/quality/trec/QueryDriver.java | 1 -
.../benchmark/byTask/feeds/DocMakerTest.java | 1 -
.../byTask/feeds/LineDocSourceTest.java | 2 +-
.../benchmark/quality/TestQualityRun.java | 1 -
.../apache/lucene/facet/FacetTestBase.java | 2 +-
.../apache/lucene/facet/FacetTestUtils.java | 1 -
.../lucene/facet/search/DrillDownTest.java | 4 -
.../search/TestMultipleCategoryLists.java | 5 -
.../AssociationsFacetRequestTest.java | 3 -
.../facet/util/TestScoredDocIDsUtils.java | 1 -
.../grouping/AllGroupHeadsCollectorTest.java | 1 -
.../lucene/search/grouping/TestGrouping.java | 2 -
.../lucene/search/join/TestBlockJoin.java | 7 -
.../lucene/queries/ChainedFilterTest.java | 2 -
.../lucene/queries/TestCustomScoreQuery.java | 3 -
.../queries/function/TestFieldScoreQuery.java | 2 -
.../queries/function/TestOrdValues.java | 2 -
.../lucene/queries/mlt/TestMoreLikeThis.java | 1 -
.../classic/TestMultiFieldQueryParser.java | 1 -
.../complexPhrase/TestComplexPhraseQuery.java | 1 -
.../standard/TestMultiFieldQPHelper.java | 1 -
.../standard/TestNumericQueryParser.java | 1 -
.../flexible/standard/TestQPHelper.java | 1 -
.../surround/query/BooleanQueryTst.java | 1 -
.../queryparser/util/QueryParserTestBase.java | 1 -
.../lucene/queryparser/xml/TestParser.java | 1 -
.../xml/TestQueryTemplateManager.java | 1 -
.../lucene/search/spell/SpellChecker.java | 3 -
.../apache/solr/search/SolrIndexSearcher.java | 4 +-
.../solr/handler/TestReplicationHandler.java | 1 -
.../test/org/apache/solr/search/TestSort.java | 1 -
157 files changed, 194 insertions(+), 542 deletions(-)
diff --git a/lucene/CHANGES.txt b/lucene/CHANGES.txt
index 754b127d4f7..2d679c8c267 100644
--- a/lucene/CHANGES.txt
+++ b/lucene/CHANGES.txt
@@ -222,6 +222,10 @@ Changes in backwards compatibility policy
FilterIndexReader, overriding FilterIndexReader.norms(). To persist the
changes on disk, copy the FilteredIndexReader to a new index using
IndexWriter.addIndexes(). (Uwe Schindler, Robert Muir)
+
+* LUCENE-3640: Removed IndexSearcher.close(), because IndexSearcher no longer
+ takes a Directory and no longer "manages" IndexReaders, it is a no-op.
+ (Robert Muir)
Changes in Runtime Behavior
diff --git a/lucene/contrib/demo/src/java/org/apache/lucene/demo/SearchFiles.java b/lucene/contrib/demo/src/java/org/apache/lucene/demo/SearchFiles.java
index 2384c99f685..7f5aa2fa737 100644
--- a/lucene/contrib/demo/src/java/org/apache/lucene/demo/SearchFiles.java
+++ b/lucene/contrib/demo/src/java/org/apache/lucene/demo/SearchFiles.java
@@ -131,7 +131,6 @@ public class SearchFiles {
break;
}
}
- searcher.close();
reader.close();
}
diff --git a/lucene/contrib/highlighter/src/test/org/apache/lucene/search/highlight/HighlighterPhraseTest.java b/lucene/contrib/highlighter/src/test/org/apache/lucene/search/highlight/HighlighterPhraseTest.java
index 32a6f3c378c..785d0345189 100644
--- a/lucene/contrib/highlighter/src/test/org/apache/lucene/search/highlight/HighlighterPhraseTest.java
+++ b/lucene/contrib/highlighter/src/test/org/apache/lucene/search/highlight/HighlighterPhraseTest.java
@@ -72,26 +72,21 @@ public class HighlighterPhraseTest extends LuceneTestCase {
try {
assertEquals(1, indexReader.numDocs());
final IndexSearcher indexSearcher = newSearcher(indexReader);
- try {
- final PhraseQuery phraseQuery = new PhraseQuery();
- phraseQuery.add(new Term(FIELD, "fox"));
- phraseQuery.add(new Term(FIELD, "jumped"));
- phraseQuery.setSlop(0);
- TopDocs hits = indexSearcher.search(phraseQuery, 1);
- assertEquals(1, hits.totalHits);
- final Highlighter highlighter = new Highlighter(
- new SimpleHTMLFormatter(), new SimpleHTMLEncoder(),
- new QueryScorer(phraseQuery));
+ final PhraseQuery phraseQuery = new PhraseQuery();
+ phraseQuery.add(new Term(FIELD, "fox"));
+ phraseQuery.add(new Term(FIELD, "jumped"));
+ phraseQuery.setSlop(0);
+ TopDocs hits = indexSearcher.search(phraseQuery, 1);
+ assertEquals(1, hits.totalHits);
+ final Highlighter highlighter = new Highlighter(
+ new SimpleHTMLFormatter(), new SimpleHTMLEncoder(),
+ new QueryScorer(phraseQuery));
- final TokenStream tokenStream = TokenSources
- .getTokenStream(indexReader.getTermVector(
- 0, FIELD), false);
- assertEquals(highlighter.getBestFragment(new TokenStreamConcurrent(),
- TEXT), highlighter.getBestFragment(tokenStream, TEXT));
-
- } finally {
- indexSearcher.close();
- }
+ final TokenStream tokenStream = TokenSources
+ .getTokenStream(indexReader.getTermVector(
+ 0, FIELD), false);
+ assertEquals(highlighter.getBestFragment(new TokenStreamConcurrent(),
+ TEXT), highlighter.getBestFragment(tokenStream, TEXT));
} finally {
indexReader.close();
directory.close();
@@ -120,52 +115,48 @@ public class HighlighterPhraseTest extends LuceneTestCase {
try {
assertEquals(1, indexReader.numDocs());
final IndexSearcher indexSearcher = newSearcher(indexReader);
- try {
- final Query phraseQuery = new SpanNearQuery(new SpanQuery[] {
- new SpanTermQuery(new Term(FIELD, "fox")),
- new SpanTermQuery(new Term(FIELD, "jumped")) }, 0, true);
- final FixedBitSet bitset = new FixedBitSet(indexReader.maxDoc());
- indexSearcher.search(phraseQuery, new Collector() {
- private int baseDoc;
+ final Query phraseQuery = new SpanNearQuery(new SpanQuery[] {
+ new SpanTermQuery(new Term(FIELD, "fox")),
+ new SpanTermQuery(new Term(FIELD, "jumped")) }, 0, true);
+ final FixedBitSet bitset = new FixedBitSet(indexReader.maxDoc());
+ indexSearcher.search(phraseQuery, new Collector() {
+ private int baseDoc;
- @Override
- public boolean acceptsDocsOutOfOrder() {
- return true;
- }
-
- @Override
- public void collect(int i) throws IOException {
- bitset.set(this.baseDoc + i);
- }
-
- @Override
- public void setNextReader(AtomicReaderContext context)
- throws IOException {
- this.baseDoc = context.docBase;
- }
-
- @Override
- public void setScorer(org.apache.lucene.search.Scorer scorer)
- throws IOException {
- // Do Nothing
- }
- });
- assertEquals(1, bitset.cardinality());
- final int maxDoc = indexReader.maxDoc();
- final Highlighter highlighter = new Highlighter(
- new SimpleHTMLFormatter(), new SimpleHTMLEncoder(),
- new QueryScorer(phraseQuery));
- for (int position = bitset.nextSetBit(0); position >= 0 && position < maxDoc-1; position = bitset
- .nextSetBit(position + 1)) {
- assertEquals(0, position);
- final TokenStream tokenStream = TokenSources.getTokenStream(
- indexReader.getTermVector(position,
- FIELD), false);
- assertEquals(highlighter.getBestFragment(new TokenStreamConcurrent(),
- TEXT), highlighter.getBestFragment(tokenStream, TEXT));
+ @Override
+ public boolean acceptsDocsOutOfOrder() {
+ return true;
}
- } finally {
- indexSearcher.close();
+
+ @Override
+ public void collect(int i) throws IOException {
+ bitset.set(this.baseDoc + i);
+ }
+
+ @Override
+ public void setNextReader(AtomicReaderContext context)
+ throws IOException {
+ this.baseDoc = context.docBase;
+ }
+
+ @Override
+ public void setScorer(org.apache.lucene.search.Scorer scorer)
+ throws IOException {
+ // Do Nothing
+ }
+ });
+ assertEquals(1, bitset.cardinality());
+ final int maxDoc = indexReader.maxDoc();
+ final Highlighter highlighter = new Highlighter(
+ new SimpleHTMLFormatter(), new SimpleHTMLEncoder(),
+ new QueryScorer(phraseQuery));
+ for (int position = bitset.nextSetBit(0); position >= 0 && position < maxDoc-1; position = bitset
+ .nextSetBit(position + 1)) {
+ assertEquals(0, position);
+ final TokenStream tokenStream = TokenSources.getTokenStream(
+ indexReader.getTermVector(position,
+ FIELD), false);
+ assertEquals(highlighter.getBestFragment(new TokenStreamConcurrent(),
+ TEXT), highlighter.getBestFragment(tokenStream, TEXT));
}
} finally {
indexReader.close();
@@ -195,25 +186,21 @@ public class HighlighterPhraseTest extends LuceneTestCase {
try {
assertEquals(1, indexReader.numDocs());
final IndexSearcher indexSearcher = newSearcher(indexReader);
- try {
- final PhraseQuery phraseQuery = new PhraseQuery();
- phraseQuery.add(new Term(FIELD, "did"));
- phraseQuery.add(new Term(FIELD, "jump"));
- phraseQuery.setSlop(0);
- TopDocs hits = indexSearcher.search(phraseQuery, 1);
- assertEquals(0, hits.totalHits);
- final Highlighter highlighter = new Highlighter(
- new SimpleHTMLFormatter(), new SimpleHTMLEncoder(),
- new QueryScorer(phraseQuery));
- final TokenStream tokenStream = TokenSources
- .getTokenStream(indexReader.getTermVector(
- 0, FIELD), false);
- assertEquals(
- highlighter.getBestFragment(new TokenStreamSparse(), TEXT),
- highlighter.getBestFragment(tokenStream, TEXT));
- } finally {
- indexSearcher.close();
- }
+ final PhraseQuery phraseQuery = new PhraseQuery();
+ phraseQuery.add(new Term(FIELD, "did"));
+ phraseQuery.add(new Term(FIELD, "jump"));
+ phraseQuery.setSlop(0);
+ TopDocs hits = indexSearcher.search(phraseQuery, 1);
+ assertEquals(0, hits.totalHits);
+ final Highlighter highlighter = new Highlighter(
+ new SimpleHTMLFormatter(), new SimpleHTMLEncoder(),
+ new QueryScorer(phraseQuery));
+ final TokenStream tokenStream = TokenSources
+ .getTokenStream(indexReader.getTermVector(
+ 0, FIELD), false);
+ assertEquals(
+ highlighter.getBestFragment(new TokenStreamSparse(), TEXT),
+ highlighter.getBestFragment(tokenStream, TEXT));
} finally {
indexReader.close();
directory.close();
@@ -241,23 +228,19 @@ public class HighlighterPhraseTest extends LuceneTestCase {
try {
assertEquals(1, indexReader.numDocs());
final IndexSearcher indexSearcher = newSearcher(indexReader);
- try {
- final PhraseQuery phraseQuery = new PhraseQuery();
- phraseQuery.add(new Term(FIELD, "did"));
- phraseQuery.add(new Term(FIELD, "jump"));
- phraseQuery.setSlop(1);
- TopDocs hits = indexSearcher.search(phraseQuery, 1);
- assertEquals(1, hits.totalHits);
- final Highlighter highlighter = new Highlighter(
- new SimpleHTMLFormatter(), new SimpleHTMLEncoder(),
- new QueryScorer(phraseQuery));
- final TokenStream tokenStream = TokenSources.getTokenStream(
- indexReader.getTermVector(0, FIELD), true);
- assertEquals("the fox did not jump", highlighter
- .getBestFragment(tokenStream, TEXT));
- } finally {
- indexSearcher.close();
- }
+ final PhraseQuery phraseQuery = new PhraseQuery();
+ phraseQuery.add(new Term(FIELD, "did"));
+ phraseQuery.add(new Term(FIELD, "jump"));
+ phraseQuery.setSlop(1);
+ TopDocs hits = indexSearcher.search(phraseQuery, 1);
+ assertEquals(1, hits.totalHits);
+ final Highlighter highlighter = new Highlighter(
+ new SimpleHTMLFormatter(), new SimpleHTMLEncoder(),
+ new QueryScorer(phraseQuery));
+ final TokenStream tokenStream = TokenSources.getTokenStream(
+ indexReader.getTermVector(0, FIELD), true);
+ assertEquals("the fox did not jump", highlighter
+ .getBestFragment(tokenStream, TEXT));
} finally {
indexReader.close();
directory.close();
@@ -285,25 +268,21 @@ public class HighlighterPhraseTest extends LuceneTestCase {
try {
assertEquals(1, indexReader.numDocs());
final IndexSearcher indexSearcher = newSearcher(indexReader);
- try {
- final Query phraseQuery = new SpanNearQuery(new SpanQuery[] {
- new SpanTermQuery(new Term(FIELD, "did")),
- new SpanTermQuery(new Term(FIELD, "jump")) }, 0, true);
+ final Query phraseQuery = new SpanNearQuery(new SpanQuery[] {
+ new SpanTermQuery(new Term(FIELD, "did")),
+ new SpanTermQuery(new Term(FIELD, "jump")) }, 0, true);
- TopDocs hits = indexSearcher.search(phraseQuery, 1);
- assertEquals(0, hits.totalHits);
- final Highlighter highlighter = new Highlighter(
- new SimpleHTMLFormatter(), new SimpleHTMLEncoder(),
- new QueryScorer(phraseQuery));
- final TokenStream tokenStream = TokenSources
- .getTokenStream(indexReader.getTermVector(
- 0, FIELD), false);
- assertEquals(
- highlighter.getBestFragment(new TokenStreamSparse(), TEXT),
- highlighter.getBestFragment(tokenStream, TEXT));
- } finally {
- indexSearcher.close();
- }
+ TopDocs hits = indexSearcher.search(phraseQuery, 1);
+ assertEquals(0, hits.totalHits);
+ final Highlighter highlighter = new Highlighter(
+ new SimpleHTMLFormatter(), new SimpleHTMLEncoder(),
+ new QueryScorer(phraseQuery));
+ final TokenStream tokenStream = TokenSources
+ .getTokenStream(indexReader.getTermVector(
+ 0, FIELD), false);
+ assertEquals(
+ highlighter.getBestFragment(new TokenStreamSparse(), TEXT),
+ highlighter.getBestFragment(tokenStream, TEXT));
} finally {
indexReader.close();
directory.close();
diff --git a/lucene/contrib/highlighter/src/test/org/apache/lucene/search/highlight/HighlighterTest.java b/lucene/contrib/highlighter/src/test/org/apache/lucene/search/highlight/HighlighterTest.java
index b37c08be0be..d7dcaa511f1 100644
--- a/lucene/contrib/highlighter/src/test/org/apache/lucene/search/highlight/HighlighterTest.java
+++ b/lucene/contrib/highlighter/src/test/org/apache/lucene/search/highlight/HighlighterTest.java
@@ -109,7 +109,6 @@ public class HighlighterTest extends BaseTokenStreamTestCase implements Formatte
if (VERBOSE) System.out.println(fragment);
}
- searcher.close();
}
public void testHighlightingWithDefaultField() throws Exception {
@@ -1271,7 +1270,6 @@ public class HighlighterTest extends BaseTokenStreamTestCase implements Formatte
public void run() throws Exception {
numHighlights = 0;
// test to show how rewritten query can still be used
- if (searcher != null) searcher.close();
searcher = new IndexSearcher(reader);
Analyzer analyzer = new MockAnalyzer(random, MockTokenizer.SIMPLE, true, MockTokenFilter.ENGLISH_STOPSET, true);
@@ -1664,7 +1662,6 @@ public class HighlighterTest extends BaseTokenStreamTestCase implements Formatte
if (VERBOSE) System.out.println("result:" + result);
assertEquals("more random words for second field", result);
}
- searcher.close();
reader.close();
}
@@ -1703,7 +1700,6 @@ public class HighlighterTest extends BaseTokenStreamTestCase implements Formatte
}
public void doSearching(Query unReWrittenQuery) throws Exception {
- if (searcher != null) searcher.close();
searcher = new IndexSearcher(reader);
// for any multi-term queries to work (prefix, wildcard, range,fuzzy etc)
// you must use a rewritten query!
@@ -1769,7 +1765,6 @@ public class HighlighterTest extends BaseTokenStreamTestCase implements Formatte
@Override
public void tearDown() throws Exception {
- if (searcher != null) searcher.close();
reader.close();
dir.close();
ramDir.close();
diff --git a/lucene/contrib/highlighter/src/test/org/apache/lucene/search/highlight/TokenSourcesTest.java b/lucene/contrib/highlighter/src/test/org/apache/lucene/search/highlight/TokenSourcesTest.java
index 2622b8c9b16..3e8c09a47b8 100644
--- a/lucene/contrib/highlighter/src/test/org/apache/lucene/search/highlight/TokenSourcesTest.java
+++ b/lucene/contrib/highlighter/src/test/org/apache/lucene/search/highlight/TokenSourcesTest.java
@@ -114,31 +114,27 @@ public class TokenSourcesTest extends LuceneTestCase {
indexWriter.close();
}
final IndexReader indexReader = IndexReader.open(directory);
+ assertEquals(1, indexReader.numDocs());
+ final IndexSearcher indexSearcher = newSearcher(indexReader);
try {
- assertEquals(1, indexReader.numDocs());
- final IndexSearcher indexSearcher = newSearcher(indexReader);
- try {
- final DisjunctionMaxQuery query = new DisjunctionMaxQuery(1);
- query.add(new SpanTermQuery(new Term(FIELD, "{fox}")));
- query.add(new SpanTermQuery(new Term(FIELD, "fox")));
+ final DisjunctionMaxQuery query = new DisjunctionMaxQuery(1);
+ query.add(new SpanTermQuery(new Term(FIELD, "{fox}")));
+ query.add(new SpanTermQuery(new Term(FIELD, "fox")));
// final Query phraseQuery = new SpanNearQuery(new SpanQuery[] {
// new SpanTermQuery(new Term(FIELD, "{fox}")),
// new SpanTermQuery(new Term(FIELD, "fox")) }, 0, true);
- TopDocs hits = indexSearcher.search(query, 1);
- assertEquals(1, hits.totalHits);
- final Highlighter highlighter = new Highlighter(
- new SimpleHTMLFormatter(), new SimpleHTMLEncoder(),
- new QueryScorer(query));
- final TokenStream tokenStream = TokenSources
- .getTokenStream(
- indexReader.getTermVector(0, FIELD),
- false);
- assertEquals("the fox did not jump",
- highlighter.getBestFragment(tokenStream, TEXT));
- } finally {
- indexSearcher.close();
- }
+ TopDocs hits = indexSearcher.search(query, 1);
+ assertEquals(1, hits.totalHits);
+ final Highlighter highlighter = new Highlighter(
+ new SimpleHTMLFormatter(), new SimpleHTMLEncoder(),
+ new QueryScorer(query));
+ final TokenStream tokenStream = TokenSources
+ .getTokenStream(
+ indexReader.getTermVector(0, FIELD),
+ false);
+ assertEquals("the fox did not jump",
+ highlighter.getBestFragment(tokenStream, TEXT));
} finally {
indexReader.close();
directory.close();
@@ -166,28 +162,24 @@ public class TokenSourcesTest extends LuceneTestCase {
try {
assertEquals(1, indexReader.numDocs());
final IndexSearcher indexSearcher = newSearcher(indexReader);
- try {
- final DisjunctionMaxQuery query = new DisjunctionMaxQuery(1);
- query.add(new SpanTermQuery(new Term(FIELD, "{fox}")));
- query.add(new SpanTermQuery(new Term(FIELD, "fox")));
- // final Query phraseQuery = new SpanNearQuery(new SpanQuery[] {
- // new SpanTermQuery(new Term(FIELD, "{fox}")),
- // new SpanTermQuery(new Term(FIELD, "fox")) }, 0, true);
+ final DisjunctionMaxQuery query = new DisjunctionMaxQuery(1);
+ query.add(new SpanTermQuery(new Term(FIELD, "{fox}")));
+ query.add(new SpanTermQuery(new Term(FIELD, "fox")));
+ // final Query phraseQuery = new SpanNearQuery(new SpanQuery[] {
+ // new SpanTermQuery(new Term(FIELD, "{fox}")),
+ // new SpanTermQuery(new Term(FIELD, "fox")) }, 0, true);
- TopDocs hits = indexSearcher.search(query, 1);
- assertEquals(1, hits.totalHits);
- final Highlighter highlighter = new Highlighter(
- new SimpleHTMLFormatter(), new SimpleHTMLEncoder(),
- new QueryScorer(query));
- final TokenStream tokenStream = TokenSources
- .getTokenStream(
- indexReader.getTermVector(0, FIELD),
- false);
- assertEquals("the fox did not jump",
- highlighter.getBestFragment(tokenStream, TEXT));
- } finally {
- indexSearcher.close();
- }
+ TopDocs hits = indexSearcher.search(query, 1);
+ assertEquals(1, hits.totalHits);
+ final Highlighter highlighter = new Highlighter(
+ new SimpleHTMLFormatter(), new SimpleHTMLEncoder(),
+ new QueryScorer(query));
+ final TokenStream tokenStream = TokenSources
+ .getTokenStream(
+ indexReader.getTermVector(0, FIELD),
+ false);
+ assertEquals("the fox did not jump",
+ highlighter.getBestFragment(tokenStream, TEXT));
} finally {
indexReader.close();
directory.close();
@@ -214,28 +206,24 @@ public class TokenSourcesTest extends LuceneTestCase {
try {
assertEquals(1, indexReader.numDocs());
final IndexSearcher indexSearcher = newSearcher(indexReader);
- try {
- // final DisjunctionMaxQuery query = new DisjunctionMaxQuery(1);
- // query.add(new SpanTermQuery(new Term(FIELD, "{fox}")));
- // query.add(new SpanTermQuery(new Term(FIELD, "fox")));
- final Query phraseQuery = new SpanNearQuery(new SpanQuery[] {
- new SpanTermQuery(new Term(FIELD, "the")),
- new SpanTermQuery(new Term(FIELD, "fox"))}, 0, true);
+ // final DisjunctionMaxQuery query = new DisjunctionMaxQuery(1);
+ // query.add(new SpanTermQuery(new Term(FIELD, "{fox}")));
+ // query.add(new SpanTermQuery(new Term(FIELD, "fox")));
+ final Query phraseQuery = new SpanNearQuery(new SpanQuery[] {
+ new SpanTermQuery(new Term(FIELD, "the")),
+ new SpanTermQuery(new Term(FIELD, "fox"))}, 0, true);
- TopDocs hits = indexSearcher.search(phraseQuery, 1);
- assertEquals(1, hits.totalHits);
- final Highlighter highlighter = new Highlighter(
- new SimpleHTMLFormatter(), new SimpleHTMLEncoder(),
- new QueryScorer(phraseQuery));
- final TokenStream tokenStream = TokenSources
- .getTokenStream(
- indexReader.getTermVector(0, FIELD),
- false);
- assertEquals("the fox did not jump",
- highlighter.getBestFragment(tokenStream, TEXT));
- } finally {
- indexSearcher.close();
- }
+ TopDocs hits = indexSearcher.search(phraseQuery, 1);
+ assertEquals(1, hits.totalHits);
+ final Highlighter highlighter = new Highlighter(
+ new SimpleHTMLFormatter(), new SimpleHTMLEncoder(),
+ new QueryScorer(phraseQuery));
+ final TokenStream tokenStream = TokenSources
+ .getTokenStream(
+ indexReader.getTermVector(0, FIELD),
+ false);
+ assertEquals("the fox did not jump",
+ highlighter.getBestFragment(tokenStream, TEXT));
} finally {
indexReader.close();
directory.close();
@@ -263,28 +251,24 @@ public class TokenSourcesTest extends LuceneTestCase {
try {
assertEquals(1, indexReader.numDocs());
final IndexSearcher indexSearcher = newSearcher(indexReader);
- try {
- // final DisjunctionMaxQuery query = new DisjunctionMaxQuery(1);
- // query.add(new SpanTermQuery(new Term(FIELD, "the")));
- // query.add(new SpanTermQuery(new Term(FIELD, "fox")));
- final Query phraseQuery = new SpanNearQuery(new SpanQuery[] {
- new SpanTermQuery(new Term(FIELD, "the")),
- new SpanTermQuery(new Term(FIELD, "fox"))}, 0, true);
+ // final DisjunctionMaxQuery query = new DisjunctionMaxQuery(1);
+ // query.add(new SpanTermQuery(new Term(FIELD, "the")));
+ // query.add(new SpanTermQuery(new Term(FIELD, "fox")));
+ final Query phraseQuery = new SpanNearQuery(new SpanQuery[] {
+ new SpanTermQuery(new Term(FIELD, "the")),
+ new SpanTermQuery(new Term(FIELD, "fox"))}, 0, true);
- TopDocs hits = indexSearcher.search(phraseQuery, 1);
- assertEquals(1, hits.totalHits);
- final Highlighter highlighter = new Highlighter(
- new SimpleHTMLFormatter(), new SimpleHTMLEncoder(),
- new QueryScorer(phraseQuery));
- final TokenStream tokenStream = TokenSources
- .getTokenStream(
- indexReader.getTermVector(0, FIELD),
- false);
- assertEquals("the fox did not jump",
- highlighter.getBestFragment(tokenStream, TEXT));
- } finally {
- indexSearcher.close();
- }
+ TopDocs hits = indexSearcher.search(phraseQuery, 1);
+ assertEquals(1, hits.totalHits);
+ final Highlighter highlighter = new Highlighter(
+ new SimpleHTMLFormatter(), new SimpleHTMLEncoder(),
+ new QueryScorer(phraseQuery));
+ final TokenStream tokenStream = TokenSources
+ .getTokenStream(
+ indexReader.getTermVector(0, FIELD),
+ false);
+ assertEquals("the fox did not jump",
+ highlighter.getBestFragment(tokenStream, TEXT));
} finally {
indexReader.close();
directory.close();
diff --git a/lucene/contrib/memory/src/test/org/apache/lucene/index/memory/MemoryIndexTest.java b/lucene/contrib/memory/src/test/org/apache/lucene/index/memory/MemoryIndexTest.java
index 10d08de9939..ed821630285 100644
--- a/lucene/contrib/memory/src/test/org/apache/lucene/index/memory/MemoryIndexTest.java
+++ b/lucene/contrib/memory/src/test/org/apache/lucene/index/memory/MemoryIndexTest.java
@@ -143,9 +143,7 @@ public class MemoryIndexTest extends BaseTokenStreamTestCase {
TopDocs memDocs = mem.search(qp.parse(query), 1);
assertEquals(ramDocs.totalHits, memDocs.totalHits);
}
- ram.close();
reader.close();
- mem.close();
}
/**
diff --git a/lucene/contrib/sandbox/src/test/org/apache/lucene/sandbox/queries/DuplicateFilterTest.java b/lucene/contrib/sandbox/src/test/org/apache/lucene/sandbox/queries/DuplicateFilterTest.java
index bb27cccfe90..ef298136966 100644
--- a/lucene/contrib/sandbox/src/test/org/apache/lucene/sandbox/queries/DuplicateFilterTest.java
+++ b/lucene/contrib/sandbox/src/test/org/apache/lucene/sandbox/queries/DuplicateFilterTest.java
@@ -69,7 +69,6 @@ public class DuplicateFilterTest extends LuceneTestCase {
@Override
public void tearDown() throws Exception {
reader.close();
- searcher.close();
directory.close();
super.tearDown();
}
diff --git a/lucene/contrib/sandbox/src/test/org/apache/lucene/sandbox/queries/FuzzyLikeThisQueryTest.java b/lucene/contrib/sandbox/src/test/org/apache/lucene/sandbox/queries/FuzzyLikeThisQueryTest.java
index f3f188d99d5..823a9237f8b 100644
--- a/lucene/contrib/sandbox/src/test/org/apache/lucene/sandbox/queries/FuzzyLikeThisQueryTest.java
+++ b/lucene/contrib/sandbox/src/test/org/apache/lucene/sandbox/queries/FuzzyLikeThisQueryTest.java
@@ -60,7 +60,6 @@ public class FuzzyLikeThisQueryTest extends LuceneTestCase {
@Override
public void tearDown() throws Exception {
- searcher.close();
reader.close();
directory.close();
super.tearDown();
diff --git a/lucene/contrib/sandbox/src/test/org/apache/lucene/sandbox/queries/TestSlowCollationMethods.java b/lucene/contrib/sandbox/src/test/org/apache/lucene/sandbox/queries/TestSlowCollationMethods.java
index f3f5abf30ad..0771f1cbf86 100644
--- a/lucene/contrib/sandbox/src/test/org/apache/lucene/sandbox/queries/TestSlowCollationMethods.java
+++ b/lucene/contrib/sandbox/src/test/org/apache/lucene/sandbox/queries/TestSlowCollationMethods.java
@@ -71,7 +71,6 @@ public class TestSlowCollationMethods extends LuceneTestCase {
@AfterClass
public static void afterClass() throws Exception {
- searcher.close();
reader.close();
dir.close();
collator = null;
diff --git a/lucene/contrib/sandbox/src/test/org/apache/lucene/sandbox/queries/regex/TestRegexQuery.java b/lucene/contrib/sandbox/src/test/org/apache/lucene/sandbox/queries/regex/TestRegexQuery.java
index 84bb957a230..d72d516951f 100644
--- a/lucene/contrib/sandbox/src/test/org/apache/lucene/sandbox/queries/regex/TestRegexQuery.java
+++ b/lucene/contrib/sandbox/src/test/org/apache/lucene/sandbox/queries/regex/TestRegexQuery.java
@@ -56,7 +56,6 @@ public class TestRegexQuery extends LuceneTestCase {
@Override
public void tearDown() throws Exception {
- searcher.close();
reader.close();
directory.close();
super.tearDown();
diff --git a/lucene/contrib/sandbox/src/test/org/apache/lucene/sandbox/queries/regex/TestSpanRegexQuery.java b/lucene/contrib/sandbox/src/test/org/apache/lucene/sandbox/queries/regex/TestSpanRegexQuery.java
index 1057098bec3..4866cd7829b 100644
--- a/lucene/contrib/sandbox/src/test/org/apache/lucene/sandbox/queries/regex/TestSpanRegexQuery.java
+++ b/lucene/contrib/sandbox/src/test/org/apache/lucene/sandbox/queries/regex/TestSpanRegexQuery.java
@@ -80,7 +80,6 @@ public class TestSpanRegexQuery extends LuceneTestCase {
// true);
int numHits = searcher.search(sfq, null, 1000).totalHits;
assertEquals(1, numHits);
- searcher.close();
reader.close();
directory.close();
}
diff --git a/lucene/contrib/spatial/src/test/org/apache/lucene/spatial/tier/TestCartesian.java b/lucene/contrib/spatial/src/test/org/apache/lucene/spatial/tier/TestCartesian.java
index 33f5d4574ab..d17cf7a25e0 100644
--- a/lucene/contrib/spatial/src/test/org/apache/lucene/spatial/tier/TestCartesian.java
+++ b/lucene/contrib/spatial/src/test/org/apache/lucene/spatial/tier/TestCartesian.java
@@ -260,7 +260,6 @@ public class TestCartesian extends LuceneTestCase {
assertTrue(geo_distance >= lastDistance);
lastDistance = geo_distance;
}
- searcher.close();
reader.close();
}
@@ -332,7 +331,6 @@ public class TestCartesian extends LuceneTestCase {
assertTrue(geo_distance >= lastDistance);
lastDistance = geo_distance;
}
- searcher.close();
reader.close();
}
@@ -404,7 +402,6 @@ public class TestCartesian extends LuceneTestCase {
lastDistance = geo_distance;
}
}
- searcher.close();
reader.close();
}
@@ -476,7 +473,6 @@ public class TestCartesian extends LuceneTestCase {
}
}
- searcher.close();
reader.close();
}
}
diff --git a/lucene/src/java/org/apache/lucene/search/IndexSearcher.java b/lucene/src/java/org/apache/lucene/search/IndexSearcher.java
index 3e8112307ee..585eda8b45c 100644
--- a/lucene/src/java/org/apache/lucene/search/IndexSearcher.java
+++ b/lucene/src/java/org/apache/lucene/search/IndexSearcher.java
@@ -42,8 +42,6 @@ import org.apache.lucene.index.Terms;
import org.apache.lucene.search.similarities.DefaultSimilarityProvider;
import org.apache.lucene.search.similarities.SimilarityProvider;
import org.apache.lucene.store.NIOFSDirectory; // javadoc
-import org.apache.lucene.util.Bits;
-import org.apache.lucene.util.BytesRef;
import org.apache.lucene.util.ReaderUtil;
import org.apache.lucene.util.TermContext;
import org.apache.lucene.util.ThreadInterruptedException;
@@ -73,7 +71,7 @@ import org.apache.lucene.util.ThreadInterruptedException;
* synchronize on the IndexSearcher
instance;
* use your own (non-Lucene) objects instead.
*/
-public class IndexSearcher implements Closeable {
+public class IndexSearcher {
final IndexReader reader; // package private for testing!
// NOTE: these members might change in incompatible ways
@@ -198,10 +196,6 @@ public class IndexSearcher implements Closeable {
public SimilarityProvider getSimilarityProvider() {
return similarityProvider;
}
-
- @Override
- public void close() throws IOException {
- }
/** @lucene.internal */
protected Query wrapFilter(Query query, Filter filter) {
diff --git a/lucene/src/test-framework/java/org/apache/lucene/analysis/CollationTestBase.java b/lucene/src/test-framework/java/org/apache/lucene/analysis/CollationTestBase.java
index ccbac85d9b5..feb205ae87f 100644
--- a/lucene/src/test-framework/java/org/apache/lucene/analysis/CollationTestBase.java
+++ b/lucene/src/test-framework/java/org/apache/lucene/analysis/CollationTestBase.java
@@ -102,7 +102,6 @@ public abstract class CollationTestBase extends LuceneTestCase {
(query, new TermRangeFilter("content", secondBeg, secondEnd, true, true), 1).scoreDocs;
assertEquals("The index Term should be included.", 1, result.length);
- searcher.close();
reader.close();
}
@@ -131,7 +130,6 @@ public abstract class CollationTestBase extends LuceneTestCase {
query = new TermRangeQuery("content", secondBeg, secondEnd, true, true);
hits = searcher.search(query, null, 1000).scoreDocs;
assertEquals("The index Term should be included.", 1, hits.length);
- searcher.close();
reader.close();
}
@@ -164,7 +162,6 @@ public abstract class CollationTestBase extends LuceneTestCase {
("content", secondBeg, secondEnd, true, true);
result = search.search(csrq, null, 1000).scoreDocs;
assertEquals("The index Term should be included.", 1, result.length);
- search.close();
}
// Test using various international locales with accented characters (which
@@ -240,7 +237,6 @@ public abstract class CollationTestBase extends LuceneTestCase {
sort.setSort(new SortField("Denmark", SortField.Type.STRING));
assertMatches(searcher, queryY, sort, dkResult);
- searcher.close();
reader.close();
}
diff --git a/lucene/src/test-framework/java/org/apache/lucene/index/ThreadedIndexingAndSearchingTestCase.java b/lucene/src/test-framework/java/org/apache/lucene/index/ThreadedIndexingAndSearchingTestCase.java
index 3ce2d9ec04a..989d81408f7 100644
--- a/lucene/src/test-framework/java/org/apache/lucene/index/ThreadedIndexingAndSearchingTestCase.java
+++ b/lucene/src/test-framework/java/org/apache/lucene/index/ThreadedIndexingAndSearchingTestCase.java
@@ -472,7 +472,6 @@ public abstract class ThreadedIndexingAndSearchingTestCase extends LuceneTestCas
IndexSearcher searcher = newSearcher(reader);
sum += searcher.search(new TermQuery(new Term("body", "united")), 10).totalHits;
- searcher.close();
if (VERBOSE) {
System.out.println("TEST: warm visited " + sum + " fields");
diff --git a/lucene/src/test-framework/java/org/apache/lucene/search/CheckHits.java b/lucene/src/test-framework/java/org/apache/lucene/search/CheckHits.java
index 4f8729aea4a..083226c3fff 100644
--- a/lucene/src/test-framework/java/org/apache/lucene/search/CheckHits.java
+++ b/lucene/src/test-framework/java/org/apache/lucene/search/CheckHits.java
@@ -116,7 +116,6 @@ public class CheckHits {
query.toString(defaultFieldName),
correct, actual);
FieldCache.DEFAULT.purge(s.getIndexReader()); // our wrapping can create insanity otherwise
- s.close();
}
}
diff --git a/lucene/src/test-framework/java/org/apache/lucene/search/QueryUtils.java b/lucene/src/test-framework/java/org/apache/lucene/search/QueryUtils.java
index f13dc7485d1..5c489f29888 100644
--- a/lucene/src/test-framework/java/org/apache/lucene/search/QueryUtils.java
+++ b/lucene/src/test-framework/java/org/apache/lucene/search/QueryUtils.java
@@ -115,13 +115,10 @@ public class QueryUtils {
IndexSearcher wrapped;
check(random, q1, wrapped = wrapUnderlyingReader(random, s, -1), false);
FieldCache.DEFAULT.purge(wrapped.getIndexReader()); // // our wrapping can create insanity otherwise
- wrapped.close();
check(random, q1, wrapped = wrapUnderlyingReader(random, s, 0), false);
FieldCache.DEFAULT.purge(wrapped.getIndexReader()); // // our wrapping can create insanity otherwise
- wrapped.close();
check(random, q1, wrapped = wrapUnderlyingReader(random, s, +1), false);
FieldCache.DEFAULT.purge(wrapped.getIndexReader()); // // our wrapping can create insanity otherwise
- wrapped.close();
}
checkExplanations(q1,s);
@@ -309,7 +306,6 @@ public class QueryUtils {
Assert.assertFalse("query's last doc was "+ lastDoc[0] +" but skipTo("+(lastDoc[0]+1)+") got to "+scorer.docID(),more);
}
leafPtr++;
- indexSearcher.close();
}
lastReader[0] = context.reader;
assert readerContextArray[leafPtr].reader == context.reader;
@@ -335,7 +331,6 @@ public class QueryUtils {
boolean more = scorer.advance(lastDoc[0] + 1) != DocIdSetIterator.NO_MORE_DOCS;
Assert.assertFalse("query's last doc was "+ lastDoc[0] +" but skipTo("+(lastDoc[0]+1)+") got to "+scorer.docID(),more);
}
- indexSearcher.close();
}
}
}
@@ -394,7 +389,6 @@ public class QueryUtils {
boolean more = scorer.advance(lastDoc[0] + 1) != DocIdSetIterator.NO_MORE_DOCS;
Assert.assertFalse("query's last doc was "+ lastDoc[0] +" but skipTo("+(lastDoc[0]+1)+") got to "+scorer.docID(),more);
}
- indexSearcher.close();
leafPtr++;
}
@@ -419,7 +413,6 @@ public class QueryUtils {
boolean more = scorer.advance(lastDoc[0] + 1) != DocIdSetIterator.NO_MORE_DOCS;
Assert.assertFalse("query's last doc was "+ lastDoc[0] +" but skipTo("+(lastDoc[0]+1)+") got to "+scorer.docID(),more);
}
- indexSearcher.close();
}
}
}
diff --git a/lucene/src/test-framework/java/org/apache/lucene/util/LuceneTestCase.java b/lucene/src/test-framework/java/org/apache/lucene/util/LuceneTestCase.java
index 7cd300fec91..9e093847e0c 100644
--- a/lucene/src/test-framework/java/org/apache/lucene/util/LuceneTestCase.java
+++ b/lucene/src/test-framework/java/org/apache/lucene/util/LuceneTestCase.java
@@ -37,6 +37,7 @@ import org.apache.lucene.analysis.Analyzer;
import org.apache.lucene.document.Field;
import org.apache.lucene.document.FieldType;
import org.apache.lucene.index.*;
+import org.apache.lucene.index.IndexReader.ReaderFinishedListener;
import org.apache.lucene.index.codecs.Codec;
import org.apache.lucene.index.codecs.PostingsFormat;
import org.apache.lucene.index.codecs.appending.AppendingCodec;
@@ -731,7 +732,8 @@ public abstract class LuceneTestCase extends Assert {
rogueThreads.put(t, true);
rogueCount++;
if (t.getName().startsWith("LuceneTestCase")) {
- System.err.println("PLEASE CLOSE YOUR INDEXSEARCHERS IN YOUR TEST!!!!");
+ // TODO: should we fail here now? really test should be failing?
+ System.err.println("PLEASE CLOSE YOUR INDEXREADERS IN YOUR TEST!!!!");
continue;
} else {
// wait on the thread to die of natural causes
@@ -1228,23 +1230,25 @@ public abstract class LuceneTestCase extends Assert {
final ExecutorService ex = (random.nextBoolean()) ? null
: Executors.newFixedThreadPool(threads = _TestUtil.nextInt(random, 1, 8),
new NamedThreadFactory("LuceneTestCase"));
- if (ex != null && VERBOSE) {
+ if (ex != null) {
+ if (VERBOSE) {
System.out.println("NOTE: newSearcher using ExecutorService with " + threads + " threads");
+ }
+ final IndexReader r0 = r;
+ r.addReaderFinishedListener(new ReaderFinishedListener() {
+ @Override
+ public void finished(IndexReader reader) {
+ // readerFinishedListener bogusly calls us with other random readers
+ // so we must check that its *actually* the one we registered it on.
+ if (reader == r0) {
+ shutdownExecutorService(ex);
+ }
+ }
+ });
}
- IndexSearcher ret = random.nextBoolean() ?
- new AssertingIndexSearcher(random, r, ex) {
- @Override
- public void close() throws IOException {
- super.close();
- shutdownExecutorService(ex);
- }
- } : new AssertingIndexSearcher(random, r.getTopReaderContext(), ex) {
- @Override
- public void close() throws IOException {
- super.close();
- shutdownExecutorService(ex);
- }
- };
+ IndexSearcher ret = random.nextBoolean()
+ ? new AssertingIndexSearcher(random, r, ex)
+ : new AssertingIndexSearcher(random, r.getTopReaderContext(), ex);
ret.setSimilarityProvider(similarityProvider);
return ret;
}
diff --git a/lucene/src/test/org/apache/lucene/TestDemo.java b/lucene/src/test/org/apache/lucene/TestDemo.java
index a27b23844e3..666533eda02 100644
--- a/lucene/src/test/org/apache/lucene/TestDemo.java
+++ b/lucene/src/test/org/apache/lucene/TestDemo.java
@@ -73,7 +73,6 @@ public class TestDemo extends LuceneTestCase {
phraseQuery.add(new Term("fieldname", "be"));
assertEquals(1, isearcher.search(phraseQuery, null, 1).totalHits);
- isearcher.close();
ireader.close();
directory.close();
}
diff --git a/lucene/src/test/org/apache/lucene/TestExternalCodecs.java b/lucene/src/test/org/apache/lucene/TestExternalCodecs.java
index 98f7e54723e..b6cd0189879 100644
--- a/lucene/src/test/org/apache/lucene/TestExternalCodecs.java
+++ b/lucene/src/test/org/apache/lucene/TestExternalCodecs.java
@@ -96,7 +96,6 @@ public class TestExternalCodecs extends LuceneTestCase {
assertEquals(NUM_DOCS-1, s.search(new TermQuery(new Term("field1", "standard")), 1).totalHits);
assertEquals(NUM_DOCS-1, s.search(new TermQuery(new Term("field2", "pulsing")), 1).totalHits);
r.close();
- s.close();
if (VERBOSE) {
System.out.println("\nTEST: now delete 2nd doc");
@@ -114,7 +113,6 @@ public class TestExternalCodecs extends LuceneTestCase {
assertEquals(0, s.search(new TermQuery(new Term("id", "44")), 1).totalHits);
r.close();
- s.close();
w.close();
diff --git a/lucene/src/test/org/apache/lucene/TestSearch.java b/lucene/src/test/org/apache/lucene/TestSearch.java
index 9f5f670cbc9..6374bee593f 100644
--- a/lucene/src/test/org/apache/lucene/TestSearch.java
+++ b/lucene/src/test/org/apache/lucene/TestSearch.java
@@ -122,7 +122,6 @@ public class TestSearch extends LuceneTestCase {
out.println(i + " " + hits[i].score + " " + d.get("contents"));
}
}
- searcher.close();
reader.close();
directory.close();
}
diff --git a/lucene/src/test/org/apache/lucene/TestSearchForDuplicates.java b/lucene/src/test/org/apache/lucene/TestSearchForDuplicates.java
index e57b053584f..5907af54f5c 100644
--- a/lucene/src/test/org/apache/lucene/TestSearchForDuplicates.java
+++ b/lucene/src/test/org/apache/lucene/TestSearchForDuplicates.java
@@ -115,8 +115,6 @@ public class TestSearchForDuplicates extends LuceneTestCase {
printHits(out, hits, searcher);
checkHits(hits, MAX_DOCS, searcher);
- searcher.close();
-
// try a new search with OR
searcher = new IndexSearcher(reader);
hits = null;
@@ -130,7 +128,6 @@ public class TestSearchForDuplicates extends LuceneTestCase {
printHits(out, hits, searcher);
checkHits(hits, MAX_DOCS, searcher);
- searcher.close();
reader.close();
directory.close();
}
diff --git a/lucene/src/test/org/apache/lucene/document/TestDocument.java b/lucene/src/test/org/apache/lucene/document/TestDocument.java
index 878d0a61935..2deeaa316d3 100644
--- a/lucene/src/test/org/apache/lucene/document/TestDocument.java
+++ b/lucene/src/test/org/apache/lucene/document/TestDocument.java
@@ -174,7 +174,6 @@ public class TestDocument extends LuceneTestCase {
doAssert(searcher.doc(hits[0].doc), true);
writer.close();
- searcher.close();
reader.close();
dir.close();
}
@@ -270,7 +269,6 @@ public class TestDocument extends LuceneTestCase {
else fail("unexpected id field");
}
writer.close();
- searcher.close();
reader.close();
dir.close();
assertEquals("did not see all IDs", 7, result);
diff --git a/lucene/src/test/org/apache/lucene/index/TestBackwardsCompatibility.java b/lucene/src/test/org/apache/lucene/index/TestBackwardsCompatibility.java
index 5d5b5bef8b7..aca8a0e74c7 100644
--- a/lucene/src/test/org/apache/lucene/index/TestBackwardsCompatibility.java
+++ b/lucene/src/test/org/apache/lucene/index/TestBackwardsCompatibility.java
@@ -336,7 +336,6 @@ public class TestBackwardsCompatibility extends LuceneTestCase {
hits = searcher.search(new TermQuery(new Term("utf8", "ab\ud917\udc17cd")), null, 1000).scoreDocs;
assertEquals(34, hits.length);
- searcher.close();
reader.close();
dir.close();
}
@@ -374,7 +373,6 @@ public class TestBackwardsCompatibility extends LuceneTestCase {
Document d = searcher.getIndexReader().document(hits[0].doc);
assertEquals("wrong first document", "21", d.get("id"));
doTestHits(hits, 44, searcher.getIndexReader());
- searcher.close();
reader.close();
// fully merge
@@ -389,7 +387,6 @@ public class TestBackwardsCompatibility extends LuceneTestCase {
d = searcher.doc(hits[0].doc);
doTestHits(hits, 44, searcher.getIndexReader());
assertEquals("wrong first document", "21", d.get("id"));
- searcher.close();
reader.close();
dir.close();
@@ -406,7 +403,6 @@ public class TestBackwardsCompatibility extends LuceneTestCase {
assertEquals("wrong number of hits", 34, hits.length);
Document d = searcher.doc(hits[0].doc);
assertEquals("wrong first document", "21", d.get("id"));
- searcher.close();
reader.close();
// fully merge
@@ -419,7 +415,6 @@ public class TestBackwardsCompatibility extends LuceneTestCase {
hits = searcher.search(new TermQuery(new Term("content", "aaa")), null, 1000).scoreDocs;
assertEquals("wrong number of hits", 34, hits.length);
doTestHits(hits, 34, searcher.getIndexReader());
- searcher.close();
reader.close();
dir.close();
@@ -664,7 +659,6 @@ public class TestBackwardsCompatibility extends LuceneTestCase {
assertTrue("value in id bounds", val >= 0L && val < 35L);
}
- searcher.close();
reader.close();
dir.close();
_TestUtil.rmDir(oldIndexDir);
diff --git a/lucene/src/test/org/apache/lucene/index/TestBinaryTerms.java b/lucene/src/test/org/apache/lucene/index/TestBinaryTerms.java
index 83dc9b1e6f9..2bd2bcd9b55 100644
--- a/lucene/src/test/org/apache/lucene/index/TestBinaryTerms.java
+++ b/lucene/src/test/org/apache/lucene/index/TestBinaryTerms.java
@@ -70,7 +70,6 @@ public class TestBinaryTerms extends LuceneTestCase {
assertEquals("" + i, is.doc(docs.scoreDocs[0].doc).get("id"));
}
- is.close();
ir.close();
dir.close();
}
diff --git a/lucene/src/test/org/apache/lucene/index/TestCodecs.java b/lucene/src/test/org/apache/lucene/index/TestCodecs.java
index 6a30123cf71..2e7763c5c6e 100644
--- a/lucene/src/test/org/apache/lucene/index/TestCodecs.java
+++ b/lucene/src/test/org/apache/lucene/index/TestCodecs.java
@@ -393,7 +393,6 @@ public class TestCodecs extends LuceneTestCase {
return searcher.search(q, null, n).scoreDocs;
}
finally {
- searcher.close();
reader.close();
}
}
diff --git a/lucene/src/test/org/apache/lucene/index/TestCrashCausesCorruptIndex.java b/lucene/src/test/org/apache/lucene/index/TestCrashCausesCorruptIndex.java
index 487b6e8fb44..396ebc75a6f 100644
--- a/lucene/src/test/org/apache/lucene/index/TestCrashCausesCorruptIndex.java
+++ b/lucene/src/test/org/apache/lucene/index/TestCrashCausesCorruptIndex.java
@@ -126,7 +126,6 @@ public class TestCrashCausesCorruptIndex extends LuceneTestCase {
TopDocs topDocs = indexSearcher.search(new TermQuery(new Term(TEXT_FIELD, "fleas")), 10);
assertNotNull(topDocs);
assertEquals(expectedTotalHits, topDocs.totalHits);
- indexSearcher.close();
indexReader.close();
realDirectory.close();
}
diff --git a/lucene/src/test/org/apache/lucene/index/TestDeletionPolicy.java b/lucene/src/test/org/apache/lucene/index/TestDeletionPolicy.java
index 5b7239463cb..76e150322d5 100644
--- a/lucene/src/test/org/apache/lucene/index/TestDeletionPolicy.java
+++ b/lucene/src/test/org/apache/lucene/index/TestDeletionPolicy.java
@@ -660,7 +660,6 @@ public class TestDeletionPolicy extends LuceneTestCase {
ScoreDoc[] hits = searcher.search(query, null, 1000).scoreDocs;
assertEquals(16, hits.length);
reader.close();
- searcher.close();
writer = new IndexWriter(dir, newIndexWriterConfig(
TEST_VERSION_CURRENT, new MockAnalyzer(random))
@@ -685,7 +684,6 @@ public class TestDeletionPolicy extends LuceneTestCase {
dir.deleteFile(IndexFileNames.SEGMENTS_GEN);
int expectedCount = 0;
- searcher.close();
rwReader.close();
for(int i=0;i 0) {
searcher.doc(hits[0].doc);
}
- searcher.close();
if (refreshed != r) {
refreshed.close();
}
diff --git a/lucene/src/test/org/apache/lucene/index/TestIndexWriter.java b/lucene/src/test/org/apache/lucene/index/TestIndexWriter.java
index bf78a84faa3..2ed2aa48343 100644
--- a/lucene/src/test/org/apache/lucene/index/TestIndexWriter.java
+++ b/lucene/src/test/org/apache/lucene/index/TestIndexWriter.java
@@ -456,7 +456,6 @@ public class TestIndexWriter extends LuceneTestCase {
IndexSearcher searcher = new IndexSearcher(reader);
ScoreDoc[] hits = searcher.search(new TermQuery(new Term("field", "aaa")), null, 1000).scoreDocs;
assertEquals(300, hits.length);
- searcher.close();
reader.close();
dir.close();
@@ -488,7 +487,6 @@ public class TestIndexWriter extends LuceneTestCase {
IndexSearcher searcher = new IndexSearcher(reader);
ScoreDoc[] hits = searcher.search(new TermQuery(searchTerm), null, 1000).scoreDocs;
assertEquals(10, hits.length);
- searcher.close();
reader.close();
writer = new IndexWriter(dir, newIndexWriterConfig( TEST_VERSION_CURRENT, new MockAnalyzer(random))
@@ -511,7 +509,6 @@ public class TestIndexWriter extends LuceneTestCase {
searcher = new IndexSearcher(reader);
hits = searcher.search(new TermQuery(searchTerm), null, 1000).scoreDocs;
assertEquals(27, hits.length);
- searcher.close();
reader.close();
reader = IndexReader.open(dir);
@@ -590,7 +587,6 @@ public class TestIndexWriter extends LuceneTestCase {
IndexSearcher searcher = new IndexSearcher(reader);
ScoreDoc[] hits = searcher.search(new TermQuery(searchTerm), null, 1000).scoreDocs;
assertEquals("did not get right number of hits", 100, hits.length);
- searcher.close();
reader.close();
writer = new IndexWriter(dir, newIndexWriterConfig( TEST_VERSION_CURRENT, new MockAnalyzer(random))
@@ -1013,7 +1009,6 @@ public class TestIndexWriter extends LuceneTestCase {
assertEquals(0, tps.nextPosition());
w.close();
- s.close();
r.close();
dir.close();
}
@@ -1708,7 +1703,6 @@ public class TestIndexWriter extends LuceneTestCase {
assertEquals("doc " + testID + ", field f" + fieldCount + " is wrong", docExp.get("f"+i), doc.get("f"+i));
}
}
- s.close();
r.close();
w.forceMerge(1);
}
diff --git a/lucene/src/test/org/apache/lucene/index/TestIndexWriterCommit.java b/lucene/src/test/org/apache/lucene/index/TestIndexWriterCommit.java
index bf25a04edfa..7c9565d754a 100644
--- a/lucene/src/test/org/apache/lucene/index/TestIndexWriterCommit.java
+++ b/lucene/src/test/org/apache/lucene/index/TestIndexWriterCommit.java
@@ -55,7 +55,6 @@ public class TestIndexWriterCommit extends LuceneTestCase {
IndexSearcher searcher = new IndexSearcher(reader);
ScoreDoc[] hits = searcher.search(new TermQuery(searchTerm), null, 1000).scoreDocs;
assertEquals("first number of hits", 14, hits.length);
- searcher.close();
reader.close();
reader = IndexReader.open(dir);
@@ -69,7 +68,6 @@ public class TestIndexWriterCommit extends LuceneTestCase {
searcher = new IndexSearcher(r);
hits = searcher.search(new TermQuery(searchTerm), null, 1000).scoreDocs;
assertEquals("reader incorrectly sees changes from writer", 14, hits.length);
- searcher.close();
r.close();
assertTrue("reader should have still been current", reader.isCurrent());
}
@@ -82,7 +80,6 @@ public class TestIndexWriterCommit extends LuceneTestCase {
searcher = new IndexSearcher(r);
hits = searcher.search(new TermQuery(searchTerm), null, 1000).scoreDocs;
assertEquals("reader did not see changes after writer was closed", 47, hits.length);
- searcher.close();
r.close();
reader.close();
dir.close();
@@ -109,7 +106,6 @@ public class TestIndexWriterCommit extends LuceneTestCase {
IndexSearcher searcher = new IndexSearcher(reader);
ScoreDoc[] hits = searcher.search(new TermQuery(searchTerm), null, 1000).scoreDocs;
assertEquals("first number of hits", 14, hits.length);
- searcher.close();
reader.close();
writer = new IndexWriter(dir, newIndexWriterConfig( TEST_VERSION_CURRENT, new MockAnalyzer(random))
@@ -124,7 +120,6 @@ public class TestIndexWriterCommit extends LuceneTestCase {
searcher = new IndexSearcher(reader);
hits = searcher.search(new TermQuery(searchTerm), null, 1000).scoreDocs;
assertEquals("reader incorrectly sees changes from writer", 14, hits.length);
- searcher.close();
reader.close();
// Now, close the writer:
@@ -136,7 +131,6 @@ public class TestIndexWriterCommit extends LuceneTestCase {
searcher = new IndexSearcher(reader);
hits = searcher.search(new TermQuery(searchTerm), null, 1000).scoreDocs;
assertEquals("saw changes after writer.abort", 14, hits.length);
- searcher.close();
reader.close();
// Now make sure we can re-open the index, add docs,
@@ -156,7 +150,6 @@ public class TestIndexWriterCommit extends LuceneTestCase {
searcher = new IndexSearcher(r);
hits = searcher.search(new TermQuery(searchTerm), null, 1000).scoreDocs;
assertEquals("reader incorrectly sees changes from writer", 14, hits.length);
- searcher.close();
r.close();
}
@@ -165,7 +158,6 @@ public class TestIndexWriterCommit extends LuceneTestCase {
searcher = new IndexSearcher(r);
hits = searcher.search(new TermQuery(searchTerm), null, 1000).scoreDocs;
assertEquals("didn't see changes after close", 218, hits.length);
- searcher.close();
r.close();
dir.close();
diff --git a/lucene/src/test/org/apache/lucene/index/TestIndexWriterDelete.java b/lucene/src/test/org/apache/lucene/index/TestIndexWriterDelete.java
index b5c7680f1ca..b901f74ec9c 100644
--- a/lucene/src/test/org/apache/lucene/index/TestIndexWriterDelete.java
+++ b/lucene/src/test/org/apache/lucene/index/TestIndexWriterDelete.java
@@ -403,7 +403,6 @@ public class TestIndexWriterDelete extends LuceneTestCase {
IndexReader reader = IndexReader.open(dir);
IndexSearcher searcher = new IndexSearcher(reader);
int hitCount = searcher.search(new TermQuery(term), null, 1000).totalHits;
- searcher.close();
reader.close();
return hitCount;
}
@@ -612,7 +611,6 @@ public class TestIndexWriterDelete extends LuceneTestCase {
+ result2 + " instead of expected " + START_COUNT + " or " + END_COUNT);
}
}
- searcher.close();
newReader.close();
if (result2 == END_COUNT) {
break;
diff --git a/lucene/src/test/org/apache/lucene/index/TestIndexWriterOnDiskFull.java b/lucene/src/test/org/apache/lucene/index/TestIndexWriterOnDiskFull.java
index fbd88133806..4a7eb3b7f92 100644
--- a/lucene/src/test/org/apache/lucene/index/TestIndexWriterOnDiskFull.java
+++ b/lucene/src/test/org/apache/lucene/index/TestIndexWriterOnDiskFull.java
@@ -195,7 +195,6 @@ public class TestIndexWriterOnDiskFull extends LuceneTestCase {
IndexSearcher searcher = newSearcher(reader);
ScoreDoc[] hits = searcher.search(new TermQuery(searchTerm), null, 1000).scoreDocs;
assertEquals("first number of hits", 57, hits.length);
- searcher.close();
reader.close();
// Iterate with larger and larger amounts of free
@@ -395,7 +394,6 @@ public class TestIndexWriterOnDiskFull extends LuceneTestCase {
}
}
- searcher.close();
reader.close();
if (VERBOSE) {
System.out.println(" count is " + result);
diff --git a/lucene/src/test/org/apache/lucene/index/TestIndexWriterReader.java b/lucene/src/test/org/apache/lucene/index/TestIndexWriterReader.java
index 87d810dd5dc..aeb22d43adf 100644
--- a/lucene/src/test/org/apache/lucene/index/TestIndexWriterReader.java
+++ b/lucene/src/test/org/apache/lucene/index/TestIndexWriterReader.java
@@ -695,7 +695,6 @@ public class TestIndexWriterReader extends LuceneTestCase {
Query q = new TermQuery(new Term("indexname", "test"));
IndexSearcher searcher = newSearcher(r);
assertEquals(100, searcher.search(q, 10).totalHits);
- searcher.close();
try {
IndexReader.openIfChanged(r);
fail("failed to hit AlreadyClosedException");
@@ -761,7 +760,6 @@ public class TestIndexWriterReader extends LuceneTestCase {
Query q = new TermQuery(new Term("indexname", "test"));
IndexSearcher searcher = newSearcher(r);
final int count = searcher.search(q, 10).totalHits;
- searcher.close();
assertTrue(count >= lastCount);
lastCount = count;
}
@@ -778,7 +776,6 @@ public class TestIndexWriterReader extends LuceneTestCase {
Query q = new TermQuery(new Term("indexname", "test"));
IndexSearcher searcher = newSearcher(r);
final int count = searcher.search(q, 10).totalHits;
- searcher.close();
assertTrue(count >= lastCount);
assertEquals(0, excs.size());
@@ -850,7 +847,6 @@ public class TestIndexWriterReader extends LuceneTestCase {
Query q = new TermQuery(new Term("indexname", "test"));
IndexSearcher searcher = newSearcher(r);
sum += searcher.search(q, 10).totalHits;
- searcher.close();
}
for(int i=0;i 0);
assertEquals(0, excs.size());
@@ -954,7 +949,6 @@ public class TestIndexWriterReader extends LuceneTestCase {
TopDocs hits = s.search(new TermQuery(new Term("foo", "bar")), 10);
assertEquals(20, hits.totalHits);
didWarm.set(true);
- s.close();
}
}).
setMergePolicy(newLogMergePolicy(10))
diff --git a/lucene/src/test/org/apache/lucene/index/TestLazyProxSkipping.java b/lucene/src/test/org/apache/lucene/index/TestLazyProxSkipping.java
index e6cb02d5cb9..cd130c8c971 100755
--- a/lucene/src/test/org/apache/lucene/index/TestLazyProxSkipping.java
+++ b/lucene/src/test/org/apache/lucene/index/TestLazyProxSkipping.java
@@ -138,9 +138,7 @@ public class TestLazyProxSkipping extends LuceneTestCase {
// test whether only the minimum amount of seeks()
// are performed
performTest(5);
- searcher.close();
performTest(10);
- searcher.close();
}
public void testSeek() throws IOException {
diff --git a/lucene/src/test/org/apache/lucene/index/TestNRTThreads.java b/lucene/src/test/org/apache/lucene/index/TestNRTThreads.java
index be387e9300f..adb4ebaf7fb 100644
--- a/lucene/src/test/org/apache/lucene/index/TestNRTThreads.java
+++ b/lucene/src/test/org/apache/lucene/index/TestNRTThreads.java
@@ -100,7 +100,6 @@ public class TestNRTThreads extends ThreadedIndexingAndSearchingTestCase {
if (s != fixedSearcher) {
// Final searcher:
s.getIndexReader().close();
- s.close();
}
}
diff --git a/lucene/src/test/org/apache/lucene/index/TestOmitTf.java b/lucene/src/test/org/apache/lucene/index/TestOmitTf.java
index 2ae6ccf8615..ea5774386ec 100644
--- a/lucene/src/test/org/apache/lucene/index/TestOmitTf.java
+++ b/lucene/src/test/org/apache/lucene/index/TestOmitTf.java
@@ -400,8 +400,7 @@ public class TestOmitTf extends LuceneTestCase {
}
});
assertEquals(15, CountingHitCollector.getCount());
-
- searcher.close();
+
reader.close();
dir.close();
}
diff --git a/lucene/src/test/org/apache/lucene/index/TestParallelReader.java b/lucene/src/test/org/apache/lucene/index/TestParallelReader.java
index e9f04bb8469..86058603aae 100644
--- a/lucene/src/test/org/apache/lucene/index/TestParallelReader.java
+++ b/lucene/src/test/org/apache/lucene/index/TestParallelReader.java
@@ -46,9 +46,7 @@ public class TestParallelReader extends LuceneTestCase {
@Override
public void tearDown() throws Exception {
single.getIndexReader().close();
- single.close();
parallel.getIndexReader().close();
- parallel.close();
dir.close();
dir1.close();
dir2.close();
diff --git a/lucene/src/test/org/apache/lucene/index/TestReaderClosed.java b/lucene/src/test/org/apache/lucene/index/TestReaderClosed.java
index 9590215fedf..474ed15bb98 100644
--- a/lucene/src/test/org/apache/lucene/index/TestReaderClosed.java
+++ b/lucene/src/test/org/apache/lucene/index/TestReaderClosed.java
@@ -61,7 +61,6 @@ public class TestReaderClosed extends LuceneTestCase {
public void test() throws Exception {
TermRangeQuery query = TermRangeQuery.newStringRange("field", "a", "z", true, true);
searcher.search(query, 5);
- searcher.close();
reader.close();
try {
searcher.search(query, 5);
diff --git a/lucene/src/test/org/apache/lucene/index/TestStressIndexing.java b/lucene/src/test/org/apache/lucene/index/TestStressIndexing.java
index ee868bdc711..c109ccd150c 100644
--- a/lucene/src/test/org/apache/lucene/index/TestStressIndexing.java
+++ b/lucene/src/test/org/apache/lucene/index/TestStressIndexing.java
@@ -105,7 +105,6 @@ public class TestStressIndexing extends LuceneTestCase {
for (int i=0; i<100; i++) {
IndexReader ir = IndexReader.open(directory);
IndexSearcher is = new IndexSearcher(ir);
- is.close();
ir.close();
}
count += 100;
diff --git a/lucene/src/test/org/apache/lucene/index/TestTermsEnum2.java b/lucene/src/test/org/apache/lucene/index/TestTermsEnum2.java
index f48d83ed20f..70c12f7b89e 100644
--- a/lucene/src/test/org/apache/lucene/index/TestTermsEnum2.java
+++ b/lucene/src/test/org/apache/lucene/index/TestTermsEnum2.java
@@ -84,7 +84,6 @@ public class TestTermsEnum2 extends LuceneTestCase {
}
public void tearDown() throws Exception {
- searcher.close();
reader.close();
dir.close();
super.tearDown();
diff --git a/lucene/src/test/org/apache/lucene/index/codecs/lucene3x/TestTermInfosReaderIndex.java b/lucene/src/test/org/apache/lucene/index/codecs/lucene3x/TestTermInfosReaderIndex.java
index 827e7897c24..ce2af1e401e 100644
--- a/lucene/src/test/org/apache/lucene/index/codecs/lucene3x/TestTermInfosReaderIndex.java
+++ b/lucene/src/test/org/apache/lucene/index/codecs/lucene3x/TestTermInfosReaderIndex.java
@@ -136,7 +136,6 @@ public class TestTermInfosReaderIndex extends LuceneTestCase {
TopDocs topDocs = searcher.search(query, 10);
assertTrue(topDocs.totalHits > 0);
}
- searcher.close();
}
private List sample(IndexReader reader, int size) throws IOException {
diff --git a/lucene/src/test/org/apache/lucene/index/codecs/perfield/TestPerFieldPostingsFormat.java b/lucene/src/test/org/apache/lucene/index/codecs/perfield/TestPerFieldPostingsFormat.java
index bf9564619c6..f763804f6d0 100644
--- a/lucene/src/test/org/apache/lucene/index/codecs/perfield/TestPerFieldPostingsFormat.java
+++ b/lucene/src/test/org/apache/lucene/index/codecs/perfield/TestPerFieldPostingsFormat.java
@@ -194,7 +194,6 @@ public class TestPerFieldPostingsFormat extends LuceneTestCase {
IndexSearcher searcher = newSearcher(reader);
TopDocs search = searcher.search(new TermQuery(t), num + 10);
assertEquals(num, search.totalHits);
- searcher.close();
reader.close();
}
diff --git a/lucene/src/test/org/apache/lucene/search/TestAutomatonQuery.java b/lucene/src/test/org/apache/lucene/search/TestAutomatonQuery.java
index 2c104c3c85a..5835db9cf04 100644
--- a/lucene/src/test/org/apache/lucene/search/TestAutomatonQuery.java
+++ b/lucene/src/test/org/apache/lucene/search/TestAutomatonQuery.java
@@ -67,7 +67,6 @@ public class TestAutomatonQuery extends LuceneTestCase {
@Override
public void tearDown() throws Exception {
- searcher.close();
reader.close();
directory.close();
super.tearDown();
diff --git a/lucene/src/test/org/apache/lucene/search/TestAutomatonQueryUnicode.java b/lucene/src/test/org/apache/lucene/search/TestAutomatonQueryUnicode.java
index 149e89de66a..3e625406b88 100644
--- a/lucene/src/test/org/apache/lucene/search/TestAutomatonQueryUnicode.java
+++ b/lucene/src/test/org/apache/lucene/search/TestAutomatonQueryUnicode.java
@@ -86,7 +86,6 @@ public class TestAutomatonQueryUnicode extends LuceneTestCase {
@Override
public void tearDown() throws Exception {
- searcher.close();
reader.close();
directory.close();
super.tearDown();
diff --git a/lucene/src/test/org/apache/lucene/search/TestBoolean2.java b/lucene/src/test/org/apache/lucene/search/TestBoolean2.java
index 7e8dcc0dcab..9f89d0f2baa 100644
--- a/lucene/src/test/org/apache/lucene/search/TestBoolean2.java
+++ b/lucene/src/test/org/apache/lucene/search/TestBoolean2.java
@@ -101,12 +101,10 @@ public class TestBoolean2 extends LuceneTestCase {
@AfterClass
public static void afterClass() throws Exception {
- searcher.close();
reader.close();
littleReader.close();
dir2.close();
directory.close();
- bigSearcher.close();
searcher = null;
reader = null;
littleReader = null;
diff --git a/lucene/src/test/org/apache/lucene/search/TestBooleanMinShouldMatch.java b/lucene/src/test/org/apache/lucene/search/TestBooleanMinShouldMatch.java
index 2754cc4fd41..8901dc88fb1 100644
--- a/lucene/src/test/org/apache/lucene/search/TestBooleanMinShouldMatch.java
+++ b/lucene/src/test/org/apache/lucene/search/TestBooleanMinShouldMatch.java
@@ -73,7 +73,6 @@ public class TestBooleanMinShouldMatch extends LuceneTestCase {
@AfterClass
public static void afterClass() throws Exception {
- s.close();
s = null;
r.close();
r = null;
diff --git a/lucene/src/test/org/apache/lucene/search/TestBooleanOr.java b/lucene/src/test/org/apache/lucene/search/TestBooleanOr.java
index 5cf6493dee1..97a64f8c41d 100644
--- a/lucene/src/test/org/apache/lucene/search/TestBooleanOr.java
+++ b/lucene/src/test/org/apache/lucene/search/TestBooleanOr.java
@@ -158,7 +158,6 @@ public class TestBooleanOr extends LuceneTestCase {
@Override
public void tearDown() throws Exception {
- searcher.close();
reader.close();
dir.close();
super.tearDown();
diff --git a/lucene/src/test/org/apache/lucene/search/TestBooleanQuery.java b/lucene/src/test/org/apache/lucene/search/TestBooleanQuery.java
index 9f21dac07ea..0f4f10e2d4f 100644
--- a/lucene/src/test/org/apache/lucene/search/TestBooleanQuery.java
+++ b/lucene/src/test/org/apache/lucene/search/TestBooleanQuery.java
@@ -140,7 +140,6 @@ public class TestBooleanQuery extends LuceneTestCase {
dmq.add(pq);
assertEquals(1, s.search(dmq, 10).totalHits);
- s.close();
r.close();
w.close();
dir.close();
diff --git a/lucene/src/test/org/apache/lucene/search/TestBooleanScorer.java b/lucene/src/test/org/apache/lucene/search/TestBooleanScorer.java
index 864fbf51a02..80c1fa3e497 100644
--- a/lucene/src/test/org/apache/lucene/search/TestBooleanScorer.java
+++ b/lucene/src/test/org/apache/lucene/search/TestBooleanScorer.java
@@ -62,7 +62,6 @@ public class TestBooleanScorer extends LuceneTestCase
IndexSearcher indexSearcher = newSearcher(ir);
ScoreDoc[] hits = indexSearcher.search(query, null, 1000).scoreDocs;
assertEquals("Number of matched documents", 2, hits.length);
- indexSearcher.close();
ir.close();
directory.close();
}
@@ -122,7 +121,6 @@ public class TestBooleanScorer extends LuceneTestCase
assertEquals("should have only 1 hit", 1, hits.size());
assertEquals("hit should have been docID=3000", 3000, hits.get(0).intValue());
- searcher.close();
ir.close();
directory.close();
}
@@ -176,7 +174,6 @@ public class TestBooleanScorer extends LuceneTestCase
assertEquals(1, count[0]);
- s.close();
r.close();
d.close();
}
diff --git a/lucene/src/test/org/apache/lucene/search/TestCachingWrapperFilter.java b/lucene/src/test/org/apache/lucene/search/TestCachingWrapperFilter.java
index 43d79d64750..d46783594e2 100644
--- a/lucene/src/test/org/apache/lucene/search/TestCachingWrapperFilter.java
+++ b/lucene/src/test/org/apache/lucene/search/TestCachingWrapperFilter.java
@@ -179,7 +179,6 @@ public class TestCachingWrapperFilter extends LuceneTestCase {
writer.addDocument(doc);
reader = refreshReader(reader);
- searcher.close();
searcher = newSearcher(reader, false);
TopDocs docs = searcher.search(new MatchAllDocsQuery(), 1);
@@ -205,7 +204,6 @@ public class TestCachingWrapperFilter extends LuceneTestCase {
writer.addDocument(doc);
reader = refreshReader(reader);
- searcher.close();
searcher = newSearcher(reader, false);
docs = searcher.search(new MatchAllDocsQuery(), filter, 1);
@@ -227,7 +225,6 @@ public class TestCachingWrapperFilter extends LuceneTestCase {
writer.deleteDocuments(new Term("id", "1"));
reader = refreshReader(reader);
- searcher.close();
searcher = newSearcher(reader, false);
docs = searcher.search(new MatchAllDocsQuery(), filter, 1);
@@ -245,7 +242,6 @@ public class TestCachingWrapperFilter extends LuceneTestCase {
assertTrue(oldReader != null);
assertTrue(oldReader2 != null);
- searcher.close();
reader.close();
writer.close();
dir.close();
diff --git a/lucene/src/test/org/apache/lucene/search/TestConstantScoreQuery.java b/lucene/src/test/org/apache/lucene/search/TestConstantScoreQuery.java
index fff2a644843..325fa48404c 100644
--- a/lucene/src/test/org/apache/lucene/search/TestConstantScoreQuery.java
+++ b/lucene/src/test/org/apache/lucene/search/TestConstantScoreQuery.java
@@ -125,7 +125,6 @@ public class TestConstantScoreQuery extends LuceneTestCase {
checkHits(searcher, bq, csq1.getBoost() + csq2.getBoost(), bucketScorerClass, null);
checkHits(searcher, csqbq, csqbq.getBoost(), ConstantScoreQuery.ConstantScorer.class.getName(), bucketScorerClass);
} finally {
- if (searcher != null) searcher.close();
if (reader != null) reader.close();
if (directory != null) directory.close();
}
diff --git a/lucene/src/test/org/apache/lucene/search/TestDateFilter.java b/lucene/src/test/org/apache/lucene/search/TestDateFilter.java
index 10bf372b0fd..40a4bb4f9cf 100644
--- a/lucene/src/test/org/apache/lucene/search/TestDateFilter.java
+++ b/lucene/src/test/org/apache/lucene/search/TestDateFilter.java
@@ -97,7 +97,6 @@ public class TestDateFilter extends LuceneTestCase {
result = searcher.search(query2, df2, 1000).scoreDocs;
assertEquals(0, result.length);
- searcher.close();
reader.close();
indexStore.close();
}
@@ -164,7 +163,6 @@ public class TestDateFilter extends LuceneTestCase {
result = searcher.search(query2, df2, 1000).scoreDocs;
assertEquals(0, result.length);
- searcher.close();
reader.close();
indexStore.close();
}
diff --git a/lucene/src/test/org/apache/lucene/search/TestDateSort.java b/lucene/src/test/org/apache/lucene/search/TestDateSort.java
index 20d5cd7bc58..3031ec1a2b3 100644
--- a/lucene/src/test/org/apache/lucene/search/TestDateSort.java
+++ b/lucene/src/test/org/apache/lucene/search/TestDateSort.java
@@ -88,7 +88,6 @@ public class TestDateSort extends LuceneTestCase {
String text = document.get(TEXT_FIELD);
actualOrder[i] = text;
}
- searcher.close();
// Set up the expected order (i.e. Document 5, 4, 3, 2, 1).
String[] expectedOrder = new String[5];
diff --git a/lucene/src/test/org/apache/lucene/search/TestDisjunctionMaxQuery.java b/lucene/src/test/org/apache/lucene/search/TestDisjunctionMaxQuery.java
index 3d7f900b222..61283bf476a 100644
--- a/lucene/src/test/org/apache/lucene/search/TestDisjunctionMaxQuery.java
+++ b/lucene/src/test/org/apache/lucene/search/TestDisjunctionMaxQuery.java
@@ -163,7 +163,6 @@ public class TestDisjunctionMaxQuery extends LuceneTestCase {
@Override
public void tearDown() throws Exception {
- s.close();
r.close();
index.close();
super.tearDown();
diff --git a/lucene/src/test/org/apache/lucene/search/TestDocIdSet.java b/lucene/src/test/org/apache/lucene/search/TestDocIdSet.java
index a02dfc7b398..62224738d14 100644
--- a/lucene/src/test/org/apache/lucene/search/TestDocIdSet.java
+++ b/lucene/src/test/org/apache/lucene/search/TestDocIdSet.java
@@ -121,7 +121,6 @@ public class TestDocIdSet extends LuceneTestCase {
};
Assert.assertEquals(0, searcher.search(new MatchAllDocsQuery(), f, 10).totalHits);
- searcher.close();
reader.close();
dir.close();
}
diff --git a/lucene/src/test/org/apache/lucene/search/TestDocValuesScoring.java b/lucene/src/test/org/apache/lucene/search/TestDocValuesScoring.java
index 5fedea83927..f215e6cc4ca 100644
--- a/lucene/src/test/org/apache/lucene/search/TestDocValuesScoring.java
+++ b/lucene/src/test/org/apache/lucene/search/TestDocValuesScoring.java
@@ -133,9 +133,6 @@ public class TestDocValuesScoring extends LuceneTestCase {
assertEquals(boost.scoreDocs[0].score, noboost.scoreDocs[0].score, SCORE_EPSILON);
-
- searcher1.close();
- searcher2.close();
ir.close();
dir.close();
}
diff --git a/lucene/src/test/org/apache/lucene/search/TestElevationComparator.java b/lucene/src/test/org/apache/lucene/search/TestElevationComparator.java
index ba2f176d452..6ccd44d0518 100644
--- a/lucene/src/test/org/apache/lucene/search/TestElevationComparator.java
+++ b/lucene/src/test/org/apache/lucene/search/TestElevationComparator.java
@@ -61,7 +61,6 @@ public class TestElevationComparator extends LuceneTestCase {
runTest(searcher, true);
runTest(searcher, false);
- searcher.close();
r.close();
directory.close();
}
diff --git a/lucene/src/test/org/apache/lucene/search/TestExplanations.java b/lucene/src/test/org/apache/lucene/search/TestExplanations.java
index 49a629509ac..568636c784f 100644
--- a/lucene/src/test/org/apache/lucene/search/TestExplanations.java
+++ b/lucene/src/test/org/apache/lucene/search/TestExplanations.java
@@ -61,7 +61,6 @@ public class TestExplanations extends LuceneTestCase {
@AfterClass
public static void afterClassTestExplanations() throws Exception {
- searcher.close();
searcher = null;
reader.close();
reader = null;
diff --git a/lucene/src/test/org/apache/lucene/search/TestFieldCacheRangeFilter.java b/lucene/src/test/org/apache/lucene/search/TestFieldCacheRangeFilter.java
index b141282e5f9..1770d2d43e6 100644
--- a/lucene/src/test/org/apache/lucene/search/TestFieldCacheRangeFilter.java
+++ b/lucene/src/test/org/apache/lucene/search/TestFieldCacheRangeFilter.java
@@ -122,7 +122,6 @@ public class TestFieldCacheRangeFilter extends BaseTestRangeFilter {
result = search.search(q,FieldCacheRangeFilter.newStringRange("id",medIP,medIP,T,T), numDocs).scoreDocs;
assertEquals("med,med,T,T", 1, result.length);
- search.close();
}
@Test
@@ -185,7 +184,6 @@ public class TestFieldCacheRangeFilter extends BaseTestRangeFilter {
assertEquals("max,max,T,T", 1, result.length);
result = search.search(q,FieldCacheRangeFilter.newStringRange("rand",maxRP,null,T,F), numDocs).scoreDocs;
assertEquals("max,nul,T,T", 1, result.length);
- search.close();
}
// byte-ranges cannot be tested, because all ranges are too big for bytes, need an extra range for that
@@ -278,7 +276,6 @@ public class TestFieldCacheRangeFilter extends BaseTestRangeFilter {
assertEquals("overflow special case", 0, result.length);
result = search.search(q,FieldCacheRangeFilter.newShortRange("id",maxIdO,minIdO,T,T), numDocs).scoreDocs;
assertEquals("inverse range", 0, result.length);
- search.close();
}
@Test
@@ -370,7 +367,6 @@ public class TestFieldCacheRangeFilter extends BaseTestRangeFilter {
assertEquals("overflow special case", 0, result.length);
result = search.search(q,FieldCacheRangeFilter.newIntRange("id",maxIdO,minIdO,T,T), numDocs).scoreDocs;
assertEquals("inverse range", 0, result.length);
- search.close();
}
@Test
@@ -462,7 +458,6 @@ public class TestFieldCacheRangeFilter extends BaseTestRangeFilter {
assertEquals("overflow special case", 0, result.length);
result = search.search(q,FieldCacheRangeFilter.newLongRange("id",maxIdO,minIdO,T,T), numDocs).scoreDocs;
assertEquals("inverse range", 0, result.length);
- search.close();
}
// float and double tests are a bit minimalistic, but its complicated, because missing precision
@@ -494,7 +489,6 @@ public class TestFieldCacheRangeFilter extends BaseTestRangeFilter {
assertEquals("infinity special case", 0, result.length);
result = search.search(q,FieldCacheRangeFilter.newFloatRange("id",null,Float.valueOf(Float.NEGATIVE_INFINITY),F,F), numDocs).scoreDocs;
assertEquals("infinity special case", 0, result.length);
- search.close();
}
@Test
@@ -524,7 +518,6 @@ public class TestFieldCacheRangeFilter extends BaseTestRangeFilter {
assertEquals("infinity special case", 0, result.length);
result = search.search(q,FieldCacheRangeFilter.newDoubleRange("id",null, Double.valueOf(Double.NEGATIVE_INFINITY),F,F), numDocs).scoreDocs;
assertEquals("infinity special case", 0, result.length);
- search.close();
}
// test using a sparse index (with deleted docs).
@@ -565,7 +558,6 @@ public class TestFieldCacheRangeFilter extends BaseTestRangeFilter {
result = search.search(q,FieldCacheRangeFilter.newByteRange("id",Byte.valueOf((byte) -20),Byte.valueOf((byte) -10),T,T), 100).scoreDocs;
assertEquals("find all", 11, result.length);
- search.close();
reader.close();
dir.close();
}
diff --git a/lucene/src/test/org/apache/lucene/search/TestFieldCacheTermsFilter.java b/lucene/src/test/org/apache/lucene/search/TestFieldCacheTermsFilter.java
index 2132521ea9e..672b16a6511 100644
--- a/lucene/src/test/org/apache/lucene/search/TestFieldCacheTermsFilter.java
+++ b/lucene/src/test/org/apache/lucene/search/TestFieldCacheTermsFilter.java
@@ -68,7 +68,6 @@ public class TestFieldCacheTermsFilter extends LuceneTestCase {
results = searcher.search(q, new FieldCacheTermsFilter(fieldName, terms.toArray(new String[0])), numDocs).scoreDocs;
assertEquals("Must match 2", 2, results.length);
- searcher.close();
reader.close();
rd.close();
}
diff --git a/lucene/src/test/org/apache/lucene/search/TestFieldValueFilter.java b/lucene/src/test/org/apache/lucene/search/TestFieldValueFilter.java
index 96aa0680eb5..6dc8425691d 100644
--- a/lucene/src/test/org/apache/lucene/search/TestFieldValueFilter.java
+++ b/lucene/src/test/org/apache/lucene/search/TestFieldValueFilter.java
@@ -58,7 +58,6 @@ public class TestFieldValueFilter extends LuceneTestCase {
}
reader.close();
- searcher.close();
directory.close();
}
@@ -86,7 +85,6 @@ public class TestFieldValueFilter extends LuceneTestCase {
}
reader.close();
- searcher.close();
directory.close();
}
diff --git a/lucene/src/test/org/apache/lucene/search/TestFilteredQuery.java b/lucene/src/test/org/apache/lucene/search/TestFilteredQuery.java
index 21a9257b381..a8ef3f3f41d 100644
--- a/lucene/src/test/org/apache/lucene/search/TestFilteredQuery.java
+++ b/lucene/src/test/org/apache/lucene/search/TestFilteredQuery.java
@@ -104,7 +104,6 @@ public class TestFilteredQuery extends LuceneTestCase {
@Override
public void tearDown() throws Exception {
- searcher.close();
reader.close();
directory.close();
super.tearDown();
diff --git a/lucene/src/test/org/apache/lucene/search/TestFilteredSearch.java b/lucene/src/test/org/apache/lucene/search/TestFilteredSearch.java
index 3bb46794963..844cc575d58 100644
--- a/lucene/src/test/org/apache/lucene/search/TestFilteredSearch.java
+++ b/lucene/src/test/org/apache/lucene/search/TestFilteredSearch.java
@@ -82,7 +82,6 @@ public class TestFilteredSearch extends LuceneTestCase {
IndexSearcher indexSearcher = new IndexSearcher(reader);
ScoreDoc[] hits = indexSearcher.search(booleanQuery, filter, 1000).scoreDocs;
assertEquals("Number of matched documents", 1, hits.length);
- indexSearcher.close();
reader.close();
}
catch (IOException e) {
diff --git a/lucene/src/test/org/apache/lucene/search/TestFuzzyQuery.java b/lucene/src/test/org/apache/lucene/search/TestFuzzyQuery.java
index 3efcea057f9..62dbf88eca8 100644
--- a/lucene/src/test/org/apache/lucene/search/TestFuzzyQuery.java
+++ b/lucene/src/test/org/apache/lucene/search/TestFuzzyQuery.java
@@ -185,7 +185,6 @@ public class TestFuzzyQuery extends LuceneTestCase {
hits = searcher.search(query, null, 1000).scoreDocs;
assertEquals(0, hits.length);
- searcher.close();
reader.close();
directory.close();
}
@@ -275,7 +274,6 @@ public class TestFuzzyQuery extends LuceneTestCase {
// expecting exception
}
- searcher.close();
reader.close();
directory.close();
}
@@ -312,7 +310,6 @@ public class TestFuzzyQuery extends LuceneTestCase {
FuzzyQuery fq = new FuzzyQuery(new Term("field", "z123456"), 1f, 0, 2);
TopDocs docs = searcher.search(fq, 2);
assertEquals(5, docs.totalHits); // 5 docs, from the a and b's
- searcher.close();
mr.close();
ir1.close();
ir2.close();
@@ -353,7 +350,6 @@ public class TestFuzzyQuery extends LuceneTestCase {
hits = searcher.search(query, null, 1000).scoreDocs;
assertEquals(0, hits.length);
- searcher.close();
reader.close();
directory.close();
}
@@ -378,7 +374,6 @@ public class TestFuzzyQuery extends LuceneTestCase {
assertEquals("Lucene", reader.document(hits[0].doc).get("field"));
assertEquals("Lucene", reader.document(hits[1].doc).get("field"));
assertEquals("Lucenne", reader.document(hits[2].doc).get("field"));
- searcher.close();
reader.close();
directory.close();
}
@@ -416,7 +411,6 @@ public class TestFuzzyQuery extends LuceneTestCase {
ScoreDoc[] hits = searcher.search(q, 10).scoreDocs;
assertEquals(1, hits.length);
assertEquals("Giga byte", searcher.doc(hits[0].doc).get("field"));
- searcher.close();
r.close();
index.close();
}
@@ -457,7 +451,6 @@ public class TestFuzzyQuery extends LuceneTestCase {
assertEquals("test", searcher.doc(hits[0].doc).get("field"));
assertEquals("foobar", searcher.doc(hits[1].doc).get("field"));
- searcher.close();
reader.close();
index.close();
}
diff --git a/lucene/src/test/org/apache/lucene/search/TestFuzzyQuery2.java b/lucene/src/test/org/apache/lucene/search/TestFuzzyQuery2.java
index 53524e11514..32a9447fb29 100644
--- a/lucene/src/test/org/apache/lucene/search/TestFuzzyQuery2.java
+++ b/lucene/src/test/org/apache/lucene/search/TestFuzzyQuery2.java
@@ -139,7 +139,6 @@ public class TestFuzzyQuery2 extends LuceneTestCase {
assertEquals(Float.parseFloat(scoreDoc[1]), docs.scoreDocs[i].score, epsilon);
}
}
- searcher.close();
r.close();
dir.close();
}
diff --git a/lucene/src/test/org/apache/lucene/search/TestMatchAllDocsQuery.java b/lucene/src/test/org/apache/lucene/search/TestMatchAllDocsQuery.java
index 731cfc973e3..11050ad28e6 100644
--- a/lucene/src/test/org/apache/lucene/search/TestMatchAllDocsQuery.java
+++ b/lucene/src/test/org/apache/lucene/search/TestMatchAllDocsQuery.java
@@ -70,7 +70,6 @@ public class TestMatchAllDocsQuery extends LuceneTestCase {
assertEquals(1, hits.length);
iw.deleteDocuments(new Term("key", "one"));
- is.close();
ir.close();
ir = IndexReader.open(iw, true);
is = newSearcher(ir);
@@ -79,7 +78,6 @@ public class TestMatchAllDocsQuery extends LuceneTestCase {
assertEquals(2, hits.length);
iw.close();
- is.close();
ir.close();
dir.close();
}
diff --git a/lucene/src/test/org/apache/lucene/search/TestMultiPhraseQuery.java b/lucene/src/test/org/apache/lucene/search/TestMultiPhraseQuery.java
index f866e4a2f7d..e398fb40766 100644
--- a/lucene/src/test/org/apache/lucene/search/TestMultiPhraseQuery.java
+++ b/lucene/src/test/org/apache/lucene/search/TestMultiPhraseQuery.java
@@ -142,7 +142,6 @@ public class TestMultiPhraseQuery extends LuceneTestCase {
}
writer.close();
- searcher.close();
reader.close();
indexStore.close();
}
@@ -162,7 +161,6 @@ public class TestMultiPhraseQuery extends LuceneTestCase {
q.add(new Term("body", "chocolate"));
q.add(new Term[] {new Term("body", "pie"), new Term("body", "tart")});
assertEquals(2, searcher.search(q, 1).totalHits);
- searcher.close();
r.close();
indexStore.close();
}
@@ -205,7 +203,6 @@ public class TestMultiPhraseQuery extends LuceneTestCase {
searcher.explain(q, 0);
writer.close();
- searcher.close();
reader.close();
indexStore.close();
}
@@ -233,7 +230,6 @@ public class TestMultiPhraseQuery extends LuceneTestCase {
ScoreDoc[] hits = searcher.search(q, null, 1000).scoreDocs;
assertEquals("Wrong number of hits", 0, hits.length);
writer.close();
- searcher.close();
reader.close();
indexStore.close();
}
@@ -256,7 +252,6 @@ public class TestMultiPhraseQuery extends LuceneTestCase {
searcher.explain(q, 0);
writer.close();
- searcher.close();
reader.close();
indexStore.close();
}
@@ -330,7 +325,6 @@ public class TestMultiPhraseQuery extends LuceneTestCase {
assertEquals(10f * 10f, weight.getValueForNormalization(), 0.001f);
writer.close();
- searcher.close();
reader.close();
indexStore.close();
}
diff --git a/lucene/src/test/org/apache/lucene/search/TestMultiTermConstantScore.java b/lucene/src/test/org/apache/lucene/search/TestMultiTermConstantScore.java
index 0f07ab42890..3b4abb5db43 100644
--- a/lucene/src/test/org/apache/lucene/search/TestMultiTermConstantScore.java
+++ b/lucene/src/test/org/apache/lucene/search/TestMultiTermConstantScore.java
@@ -161,7 +161,6 @@ public class TestMultiTermConstantScore extends BaseTestRangeFilter {
result[i].score, SCORE_COMP_THRESH);
}
- search.close();
}
@Test
@@ -247,7 +246,6 @@ public class TestMultiTermConstantScore extends BaseTestRangeFilter {
Assert.assertEquals(0, hits[0].doc);
Assert.assertEquals(1, hits[1].doc);
assertTrue(hits[0].score > hits[1].score);
- search.close();
}
@Test
@@ -278,8 +276,6 @@ public class TestMultiTermConstantScore extends BaseTestRangeFilter {
assertEquals("mismatch in docid for hit#" + i, expected[i].doc,
actual[i].doc);
}
-
- search.close();
}
@Test
@@ -412,8 +408,6 @@ public class TestMultiTermConstantScore extends BaseTestRangeFilter {
result = search.search(csrq("id", medIP, medIP, T, T, MultiTermQuery.CONSTANT_SCORE_AUTO_REWRITE_DEFAULT), null, numDocs).scoreDocs;
assertEquals("med,med,T,T", 1, result.length);
-
- search.close();
}
@Test
@@ -476,7 +470,5 @@ public class TestMultiTermConstantScore extends BaseTestRangeFilter {
assertEquals("max,max,T,T", 1, result.length);
result = search.search(csrq("rand", maxRP, null, T, F), null, numDocs).scoreDocs;
assertEquals("max,nul,T,T", 1, result.length);
-
- search.close();
}
}
diff --git a/lucene/src/test/org/apache/lucene/search/TestMultiValuedNumericRangeQuery.java b/lucene/src/test/org/apache/lucene/search/TestMultiValuedNumericRangeQuery.java
index e9f4d7add4f..382d974aab4 100644
--- a/lucene/src/test/org/apache/lucene/search/TestMultiValuedNumericRangeQuery.java
+++ b/lucene/src/test/org/apache/lucene/search/TestMultiValuedNumericRangeQuery.java
@@ -73,7 +73,6 @@ public class TestMultiValuedNumericRangeQuery extends LuceneTestCase {
TopDocs nrTopDocs = searcher.search(tq, 1);
assertEquals("Returned count for NumericRangeQuery and TermRangeQuery must be equal", trTopDocs.totalHits, nrTopDocs.totalHits );
}
- searcher.close();
reader.close();
directory.close();
}
diff --git a/lucene/src/test/org/apache/lucene/search/TestNot.java b/lucene/src/test/org/apache/lucene/search/TestNot.java
index d13af0412ce..c424aade49c 100644
--- a/lucene/src/test/org/apache/lucene/search/TestNot.java
+++ b/lucene/src/test/org/apache/lucene/search/TestNot.java
@@ -51,7 +51,6 @@ public class TestNot extends LuceneTestCase {
ScoreDoc[] hits = searcher.search(query, null, 1000).scoreDocs;
assertEquals(0, hits.length);
writer.close();
- searcher.close();
reader.close();
store.close();
}
diff --git a/lucene/src/test/org/apache/lucene/search/TestNumericRangeQuery32.java b/lucene/src/test/org/apache/lucene/search/TestNumericRangeQuery32.java
index 119c6abe719..02f00fbc16d 100644
--- a/lucene/src/test/org/apache/lucene/search/TestNumericRangeQuery32.java
+++ b/lucene/src/test/org/apache/lucene/search/TestNumericRangeQuery32.java
@@ -96,7 +96,6 @@ public class TestNumericRangeQuery32 extends LuceneTestCase {
@AfterClass
public static void afterClass() throws Exception {
- searcher.close();
searcher = null;
reader.close();
reader = null;
@@ -335,7 +334,6 @@ public class TestNumericRangeQuery32 extends LuceneTestCase {
topDocs = s.search(q, 10);
assertEquals("Score doc count", TestNumericUtils.FLOAT_NANs.length, topDocs.scoreDocs.length );
- s.close();
r.close();
dir.close();
}
diff --git a/lucene/src/test/org/apache/lucene/search/TestNumericRangeQuery64.java b/lucene/src/test/org/apache/lucene/search/TestNumericRangeQuery64.java
index 6bbfa691f10..979406abe88 100644
--- a/lucene/src/test/org/apache/lucene/search/TestNumericRangeQuery64.java
+++ b/lucene/src/test/org/apache/lucene/search/TestNumericRangeQuery64.java
@@ -99,7 +99,6 @@ public class TestNumericRangeQuery64 extends LuceneTestCase {
@AfterClass
public static void afterClass() throws Exception {
- searcher.close();
searcher = null;
reader.close();
reader = null;
@@ -354,7 +353,6 @@ public class TestNumericRangeQuery64 extends LuceneTestCase {
topDocs = s.search(q, 10);
assertEquals("Score doc count", TestNumericUtils.DOUBLE_NANs.length, topDocs.scoreDocs.length );
- s.close();
r.close();
dir.close();
}
diff --git a/lucene/src/test/org/apache/lucene/search/TestPhrasePrefixQuery.java b/lucene/src/test/org/apache/lucene/search/TestPhrasePrefixQuery.java
index 7b443fbca31..d88c96b0b14 100644
--- a/lucene/src/test/org/apache/lucene/search/TestPhrasePrefixQuery.java
+++ b/lucene/src/test/org/apache/lucene/search/TestPhrasePrefixQuery.java
@@ -93,7 +93,6 @@ public class TestPhrasePrefixQuery extends LuceneTestCase {
result = searcher.search(query2, null, 1000).scoreDocs;
assertEquals(0, result.length);
- searcher.close();
reader.close();
indexStore.close();
}
diff --git a/lucene/src/test/org/apache/lucene/search/TestPhraseQuery.java b/lucene/src/test/org/apache/lucene/search/TestPhraseQuery.java
index 0612012c1ef..8d2a782dd74 100644
--- a/lucene/src/test/org/apache/lucene/search/TestPhraseQuery.java
+++ b/lucene/src/test/org/apache/lucene/search/TestPhraseQuery.java
@@ -98,7 +98,6 @@ public class TestPhraseQuery extends LuceneTestCase {
@AfterClass
public static void afterClass() throws Exception {
- searcher.close();
searcher = null;
reader.close();
reader = null;
@@ -249,7 +248,6 @@ public class TestPhraseQuery extends LuceneTestCase {
QueryUtils.check(random, query,searcher);
- searcher.close();
reader.close();
directory.close();
}
@@ -289,7 +287,6 @@ public class TestPhraseQuery extends LuceneTestCase {
QueryUtils.check(random, termQuery,searcher);
- searcher.close();
reader.close();
writer = new RandomIndexWriter(random, directory,
@@ -336,7 +333,6 @@ public class TestPhraseQuery extends LuceneTestCase {
QueryUtils.check(random, booleanQuery,searcher);
- searcher.close();
reader.close();
directory.close();
}
@@ -380,7 +376,6 @@ public class TestPhraseQuery extends LuceneTestCase {
assertEquals(0.31, hits[2].score, 0.01);
assertEquals(2, hits[2].doc);
QueryUtils.check(random, query,searcher);
- searcher.close();
reader.close();
directory.close();
}
@@ -695,7 +690,6 @@ public class TestPhraseQuery extends LuceneTestCase {
}
reader.close();
- s.close();
dir.close();
}
}
diff --git a/lucene/src/test/org/apache/lucene/search/TestPositionIncrement.java b/lucene/src/test/org/apache/lucene/search/TestPositionIncrement.java
index 6e128cfef11..688bb6005e4 100644
--- a/lucene/src/test/org/apache/lucene/search/TestPositionIncrement.java
+++ b/lucene/src/test/org/apache/lucene/search/TestPositionIncrement.java
@@ -196,7 +196,6 @@ public class TestPositionIncrement extends LuceneTestCase {
hits = searcher.search(q, null, 1000).scoreDocs;
assertEquals(0, hits.length);
- searcher.close();
reader.close();
store.close();
}
diff --git a/lucene/src/test/org/apache/lucene/search/TestPositiveScoresOnlyCollector.java b/lucene/src/test/org/apache/lucene/search/TestPositiveScoresOnlyCollector.java
index 4ef962c0518..06e1c8bdba7 100644
--- a/lucene/src/test/org/apache/lucene/search/TestPositiveScoresOnlyCollector.java
+++ b/lucene/src/test/org/apache/lucene/search/TestPositiveScoresOnlyCollector.java
@@ -89,7 +89,6 @@ public class TestPositiveScoresOnlyCollector extends LuceneTestCase {
for (int i = 0; i < sd.length; i++) {
assertTrue("only positive scores should return: " + sd[i].score, sd[i].score > 0);
}
- searcher.close();
ir.close();
directory.close();
}
diff --git a/lucene/src/test/org/apache/lucene/search/TestPrefixFilter.java b/lucene/src/test/org/apache/lucene/search/TestPrefixFilter.java
index d3168b477b1..492a647e600 100644
--- a/lucene/src/test/org/apache/lucene/search/TestPrefixFilter.java
+++ b/lucene/src/test/org/apache/lucene/search/TestPrefixFilter.java
@@ -101,7 +101,6 @@ public class TestPrefixFilter extends LuceneTestCase {
assertEquals(0, hits.length);
writer.close();
- searcher.close();
reader.close();
directory.close();
}
diff --git a/lucene/src/test/org/apache/lucene/search/TestPrefixInBooleanQuery.java b/lucene/src/test/org/apache/lucene/search/TestPrefixInBooleanQuery.java
index 673c7e89eaf..4d4d40d7011 100644
--- a/lucene/src/test/org/apache/lucene/search/TestPrefixInBooleanQuery.java
+++ b/lucene/src/test/org/apache/lucene/search/TestPrefixInBooleanQuery.java
@@ -76,7 +76,6 @@ public class TestPrefixInBooleanQuery extends LuceneTestCase {
@AfterClass
public static void afterClass() throws Exception {
- searcher.close();
searcher = null;
reader.close();
reader = null;
diff --git a/lucene/src/test/org/apache/lucene/search/TestPrefixQuery.java b/lucene/src/test/org/apache/lucene/search/TestPrefixQuery.java
index 5103c31cbb0..4a84dd3b4f7 100644
--- a/lucene/src/test/org/apache/lucene/search/TestPrefixQuery.java
+++ b/lucene/src/test/org/apache/lucene/search/TestPrefixQuery.java
@@ -61,7 +61,6 @@ public class TestPrefixQuery extends LuceneTestCase {
hits = searcher.search(query, null, 1000).scoreDocs;
assertEquals("everything", 3, hits.length);
writer.close();
- searcher.close();
reader.close();
directory.close();
}
diff --git a/lucene/src/test/org/apache/lucene/search/TestPrefixRandom.java b/lucene/src/test/org/apache/lucene/search/TestPrefixRandom.java
index cf686071a20..d55b2d75a5a 100644
--- a/lucene/src/test/org/apache/lucene/search/TestPrefixRandom.java
+++ b/lucene/src/test/org/apache/lucene/search/TestPrefixRandom.java
@@ -75,7 +75,6 @@ public class TestPrefixRandom extends LuceneTestCase {
@Override
public void tearDown() throws Exception {
reader.close();
- searcher.close();
dir.close();
super.tearDown();
}
diff --git a/lucene/src/test/org/apache/lucene/search/TestQueryWrapperFilter.java b/lucene/src/test/org/apache/lucene/search/TestQueryWrapperFilter.java
index d0d8ee2a027..47410667150 100644
--- a/lucene/src/test/org/apache/lucene/search/TestQueryWrapperFilter.java
+++ b/lucene/src/test/org/apache/lucene/search/TestQueryWrapperFilter.java
@@ -81,7 +81,6 @@ public class TestQueryWrapperFilter extends LuceneTestCase {
assertEquals(0, hits.totalHits);
hits = searcher.search(new MatchAllDocsQuery(), new CachingWrapperFilter(qwf), 10);
assertEquals(0, hits.totalHits);
- searcher.close();
reader.close();
dir.close();
}
@@ -148,7 +147,6 @@ public class TestQueryWrapperFilter extends LuceneTestCase {
assertEquals(1, td.totalHits);
}
- searcher.close();
reader.close();
dir.close();
}
diff --git a/lucene/src/test/org/apache/lucene/search/TestRegexpQuery.java b/lucene/src/test/org/apache/lucene/search/TestRegexpQuery.java
index fe4a66e902e..a3dc4824958 100644
--- a/lucene/src/test/org/apache/lucene/search/TestRegexpQuery.java
+++ b/lucene/src/test/org/apache/lucene/search/TestRegexpQuery.java
@@ -59,7 +59,6 @@ public class TestRegexpQuery extends LuceneTestCase {
@Override
public void tearDown() throws Exception {
- searcher.close();
reader.close();
directory.close();
super.tearDown();
diff --git a/lucene/src/test/org/apache/lucene/search/TestRegexpRandom.java b/lucene/src/test/org/apache/lucene/search/TestRegexpRandom.java
index 0e53a814dc1..95060cae2bc 100644
--- a/lucene/src/test/org/apache/lucene/search/TestRegexpRandom.java
+++ b/lucene/src/test/org/apache/lucene/search/TestRegexpRandom.java
@@ -95,7 +95,6 @@ public class TestRegexpRandom extends LuceneTestCase {
@Override
public void tearDown() throws Exception {
- searcher.close();
reader.close();
dir.close();
super.tearDown();
diff --git a/lucene/src/test/org/apache/lucene/search/TestRegexpRandom2.java b/lucene/src/test/org/apache/lucene/search/TestRegexpRandom2.java
index 56c695b4ede..a8aa421ee41 100644
--- a/lucene/src/test/org/apache/lucene/search/TestRegexpRandom2.java
+++ b/lucene/src/test/org/apache/lucene/search/TestRegexpRandom2.java
@@ -95,8 +95,6 @@ public class TestRegexpRandom2 extends LuceneTestCase {
@Override
public void tearDown() throws Exception {
reader.close();
- searcher1.close();
- searcher2.close();
dir.close();
super.tearDown();
}
diff --git a/lucene/src/test/org/apache/lucene/search/TestScoreCachingWrappingScorer.java b/lucene/src/test/org/apache/lucene/search/TestScoreCachingWrappingScorer.java
index 664f1810805..5f80a1fda91 100644
--- a/lucene/src/test/org/apache/lucene/search/TestScoreCachingWrappingScorer.java
+++ b/lucene/src/test/org/apache/lucene/search/TestScoreCachingWrappingScorer.java
@@ -119,7 +119,6 @@ public class TestScoreCachingWrappingScorer extends LuceneTestCase {
for (int i = 0; i < scores.length; i++) {
assertEquals(scores[i], scc.mscores[i], 0f);
}
- searcher.close();
ir.close();
directory.close();
}
diff --git a/lucene/src/test/org/apache/lucene/search/TestScorerPerf.java b/lucene/src/test/org/apache/lucene/search/TestScorerPerf.java
index 540015e5353..fccb6b03f7a 100755
--- a/lucene/src/test/org/apache/lucene/search/TestScorerPerf.java
+++ b/lucene/src/test/org/apache/lucene/search/TestScorerPerf.java
@@ -323,7 +323,6 @@ public class TestScorerPerf extends LuceneTestCase {
sets=randBitSets(atLeast(1000), atLeast(10));
doConjunctions(atLeast(10000), atLeast(5));
doNestedConjunctions(atLeast(10000), atLeast(3), atLeast(3));
- s.close();
r.close();
d.close();
}
diff --git a/lucene/src/test/org/apache/lucene/search/TestSearchAfter.java b/lucene/src/test/org/apache/lucene/search/TestSearchAfter.java
index 19d258ba71c..338973ad413 100644
--- a/lucene/src/test/org/apache/lucene/search/TestSearchAfter.java
+++ b/lucene/src/test/org/apache/lucene/search/TestSearchAfter.java
@@ -54,7 +54,6 @@ public class TestSearchAfter extends LuceneTestCase {
@Override
public void tearDown() throws Exception {
- searcher.close();
reader.close();
dir.close();
super.tearDown();
diff --git a/lucene/src/test/org/apache/lucene/search/TestSearchWithThreads.java b/lucene/src/test/org/apache/lucene/search/TestSearchWithThreads.java
index 0ff446dabb9..47f6f49bade 100644
--- a/lucene/src/test/org/apache/lucene/search/TestSearchWithThreads.java
+++ b/lucene/src/test/org/apache/lucene/search/TestSearchWithThreads.java
@@ -108,7 +108,6 @@ public class TestSearchWithThreads extends LuceneTestCase {
if (VERBOSE) System.out.println(NUM_SEARCH_THREADS + " threads did " + netSearch.get() + " searches");
- s.close();
r.close();
dir.close();
}
diff --git a/lucene/src/test/org/apache/lucene/search/TestSimilarity.java b/lucene/src/test/org/apache/lucene/search/TestSimilarity.java
index 78735e0b5c9..98c05f57cac 100644
--- a/lucene/src/test/org/apache/lucene/search/TestSimilarity.java
+++ b/lucene/src/test/org/apache/lucene/search/TestSimilarity.java
@@ -169,7 +169,6 @@ public class TestSimilarity extends LuceneTestCase {
}
});
- searcher.close();
reader.close();
store.close();
}
diff --git a/lucene/src/test/org/apache/lucene/search/TestSimilarityProvider.java b/lucene/src/test/org/apache/lucene/search/TestSimilarityProvider.java
index 9a0b908a20c..d58de905895 100644
--- a/lucene/src/test/org/apache/lucene/search/TestSimilarityProvider.java
+++ b/lucene/src/test/org/apache/lucene/search/TestSimilarityProvider.java
@@ -67,7 +67,6 @@ public class TestSimilarityProvider extends LuceneTestCase {
@Override
public void tearDown() throws Exception {
- searcher.close();
reader.close();
directory.close();
super.tearDown();
diff --git a/lucene/src/test/org/apache/lucene/search/TestSloppyPhraseQuery.java b/lucene/src/test/org/apache/lucene/search/TestSloppyPhraseQuery.java
index 7e3fb810bf7..9565b20f2d6 100755
--- a/lucene/src/test/org/apache/lucene/search/TestSloppyPhraseQuery.java
+++ b/lucene/src/test/org/apache/lucene/search/TestSloppyPhraseQuery.java
@@ -149,7 +149,6 @@ public class TestSloppyPhraseQuery extends LuceneTestCase {
//QueryUtils.check(query,searcher);
writer.close();
- searcher.close();
reader.close();
ramDir.close();
@@ -262,7 +261,6 @@ public class TestSloppyPhraseQuery extends LuceneTestCase {
assertEquals(3, is.search(pq, 4).totalHits);
pq.setSlop(2);
assertEquals(4, is.search(pq, 4).totalHits);
- is.close();
ir.close();
dir.close();
}
@@ -286,7 +284,6 @@ public class TestSloppyPhraseQuery extends LuceneTestCase {
pq.add(new Term("lyrics", "drug"), 3);
pq.setSlop(1);
assertSaneScoring(pq, is);
- is.close();
ir.close();
dir.close();
}
@@ -341,7 +338,6 @@ public class TestSloppyPhraseQuery extends LuceneTestCase {
pq.add(new Term("lyrics", "drug"), 3);
pq.setSlop(5);
assertSaneScoring(pq, is);
- is.close();
ir.close();
dir.close();
}
diff --git a/lucene/src/test/org/apache/lucene/search/TestSort.java b/lucene/src/test/org/apache/lucene/search/TestSort.java
index 6f7e8266b45..5f96a0f7638 100644
--- a/lucene/src/test/org/apache/lucene/search/TestSort.java
+++ b/lucene/src/test/org/apache/lucene/search/TestSort.java
@@ -334,9 +334,6 @@ public class TestSort extends LuceneTestCase {
full.reader.close();
searchX.reader.close();
searchY.reader.close();
- full.close();
- searchX.close();
- searchY.close();
for (Directory dir : dirs)
dir.close();
super.tearDown();
@@ -559,7 +556,6 @@ public class TestSort extends LuceneTestCase {
}
assertFalse("Found sort results out of order", fail);
searcher.getIndexReader().close();
- searcher.close();
}
/**
@@ -816,7 +812,6 @@ public class TestSort extends LuceneTestCase {
new SortField ("string", SortField.Type.STRING),
new SortField ("float", SortField.Type.FLOAT, true) );
assertMatches (parallelSearcher, queryG, sort, "ZYXW");
- parallelSearcher.close();
exec.shutdown();
exec.awaitTermination(1000, TimeUnit.MILLISECONDS);
}
@@ -855,7 +850,6 @@ public class TestSort extends LuceneTestCase {
new IndexReader[] {searchX.getIndexReader(),
searchY.getIndexReader()}), exec);
runMultiSorts(searcher, false);
- searcher.close();
exec.shutdown();
exec.awaitTermination(1000, TimeUnit.MILLISECONDS);
}
@@ -1284,7 +1278,6 @@ public class TestSort extends LuceneTestCase {
// null sorts first
assertEquals(1, hits.scoreDocs[0].doc);
assertEquals(0, hits.scoreDocs[1].doc);
- s.close();
r.close();
dir.close();
}
@@ -1308,7 +1301,6 @@ public class TestSort extends LuceneTestCase {
IndexReader reader = IndexReader.open(indexStore);
IndexSearcher searcher = new IndexSearcher(reader);
searcher.search(new MatchAllDocsQuery(), null, 500, sort);
- searcher.close();
reader.close();
indexStore.close();
}
@@ -1329,7 +1321,6 @@ public class TestSort extends LuceneTestCase {
TotalHitCountCollector c = new TotalHitCountCollector();
searcher.search(new MatchAllDocsQuery(), null, c);
assertEquals(5, c.getTotalHits());
- searcher.close();
reader.close();
indexStore.close();
}
diff --git a/lucene/src/test/org/apache/lucene/search/TestSubScorerFreqs.java b/lucene/src/test/org/apache/lucene/search/TestSubScorerFreqs.java
index f8d9e2d71aa..dd05ae44a6d 100644
--- a/lucene/src/test/org/apache/lucene/search/TestSubScorerFreqs.java
+++ b/lucene/src/test/org/apache/lucene/search/TestSubScorerFreqs.java
@@ -61,7 +61,6 @@ public class TestSubScorerFreqs extends LuceneTestCase {
@AfterClass
public static void finish() throws Exception {
s.getIndexReader().close();
- s.close();
s = null;
dir.close();
dir = null;
diff --git a/lucene/src/test/org/apache/lucene/search/TestTermRangeFilter.java b/lucene/src/test/org/apache/lucene/search/TestTermRangeFilter.java
index 1b71e611673..e1d55a2e9bf 100644
--- a/lucene/src/test/org/apache/lucene/search/TestTermRangeFilter.java
+++ b/lucene/src/test/org/apache/lucene/search/TestTermRangeFilter.java
@@ -134,8 +134,6 @@ public class TestTermRangeFilter extends BaseTestRangeFilter {
result = search.search(q, TermRangeFilter.newStringRange("id", medIP, medIP, T, T),
numDocs).scoreDocs;
assertEquals("med,med,T,T", 1, result.length);
-
- search.close();
}
@Test
@@ -212,7 +210,5 @@ public class TestTermRangeFilter extends BaseTestRangeFilter {
result = search.search(q, TermRangeFilter.newStringRange("rand", maxRP, null, T, F),
numDocs).scoreDocs;
assertEquals("max,nul,T,T", 1, result.length);
-
- search.close();
}
}
diff --git a/lucene/src/test/org/apache/lucene/search/TestTermRangeQuery.java b/lucene/src/test/org/apache/lucene/search/TestTermRangeQuery.java
index cf721456485..fed281cd2f8 100644
--- a/lucene/src/test/org/apache/lucene/search/TestTermRangeQuery.java
+++ b/lucene/src/test/org/apache/lucene/search/TestTermRangeQuery.java
@@ -59,7 +59,6 @@ public class TestTermRangeQuery extends LuceneTestCase {
IndexSearcher searcher = new IndexSearcher(reader);
ScoreDoc[] hits = searcher.search(query, null, 1000).scoreDocs;
assertEquals("A,B,C,D, only B in range", 1, hits.length);
- searcher.close();
reader.close();
initializeIndex(new String[] {"A", "B", "D"});
@@ -67,7 +66,6 @@ public class TestTermRangeQuery extends LuceneTestCase {
searcher = new IndexSearcher(reader);
hits = searcher.search(query, null, 1000).scoreDocs;
assertEquals("A,B,D, only B in range", 1, hits.length);
- searcher.close();
reader.close();
addDoc("C");
@@ -75,7 +73,6 @@ public class TestTermRangeQuery extends LuceneTestCase {
searcher = new IndexSearcher(reader);
hits = searcher.search(query, null, 1000).scoreDocs;
assertEquals("C added, still only B in range", 1, hits.length);
- searcher.close();
reader.close();
}
@@ -87,7 +84,6 @@ public class TestTermRangeQuery extends LuceneTestCase {
IndexSearcher searcher = new IndexSearcher(reader);
ScoreDoc[] hits = searcher.search(query, null, 1000).scoreDocs;
assertEquals("A,B,C,D - A,B,C in range", 3, hits.length);
- searcher.close();
reader.close();
initializeIndex(new String[]{"A", "B", "D"});
@@ -95,7 +91,6 @@ public class TestTermRangeQuery extends LuceneTestCase {
searcher = new IndexSearcher(reader);
hits = searcher.search(query, null, 1000).scoreDocs;
assertEquals("A,B,D - A and B in range", 2, hits.length);
- searcher.close();
reader.close();
addDoc("C");
@@ -103,7 +98,6 @@ public class TestTermRangeQuery extends LuceneTestCase {
searcher = new IndexSearcher(reader);
hits = searcher.search(query, null, 1000).scoreDocs;
assertEquals("C added - A, B, C in range", 3, hits.length);
- searcher.close();
reader.close();
}
@@ -125,7 +119,6 @@ public class TestTermRangeQuery extends LuceneTestCase {
query = TermRangeQuery.newStringRange("content", "B", null, true, false);
assertTrue(query.getTermsEnum(terms) instanceof TermRangeTermsEnum);
assertEquals(3, searcher.search(query, null, 1000).scoreDocs.length);
- searcher.close();
reader.close();
}
@@ -146,7 +139,6 @@ public class TestTermRangeQuery extends LuceneTestCase {
} finally {
BooleanQuery.setMaxClauseCount(savedClauseCount);
}
- searcher.close();
reader.close();
}
@@ -292,7 +284,6 @@ public class TestTermRangeQuery extends LuceneTestCase {
// until Lucene-38 is fixed, use this assert:
//assertEquals("A,B,,C,D => A, B & are in range", 2, hits.length());
- searcher.close();
reader.close();
initializeIndex(new String[] {"A", "B", "", "D"}, analyzer);
reader = IndexReader.open(dir);
@@ -302,7 +293,6 @@ public class TestTermRangeQuery extends LuceneTestCase {
assertEquals("A,B,,D => A, B & are in range", 3, numHits);
// until Lucene-38 is fixed, use this assert:
//assertEquals("A,B,,D => A, B & are in range", 2, hits.length());
- searcher.close();
reader.close();
addDoc("C");
reader = IndexReader.open(dir);
@@ -312,7 +302,6 @@ public class TestTermRangeQuery extends LuceneTestCase {
assertEquals("C added, still A, B & are in range", 3, numHits);
// until Lucene-38 is fixed, use this assert
//assertEquals("C added, still A, B & are in range", 2, hits.length());
- searcher.close();
reader.close();
}
@@ -329,7 +318,6 @@ public class TestTermRangeQuery extends LuceneTestCase {
assertEquals("A,B,,C,D => A,B,,C in range", 4, numHits);
// until Lucene-38 is fixed, use this assert
//assertEquals("A,B,,C,D => A,B,,C in range", 3, hits.length());
- searcher.close();
reader.close();
initializeIndex(new String[]{"A", "B", "", "D"}, analyzer);
reader = IndexReader.open(dir);
@@ -339,7 +327,6 @@ public class TestTermRangeQuery extends LuceneTestCase {
assertEquals("A,B,,D - A, B and in range", 3, numHits);
// until Lucene-38 is fixed, use this assert
//assertEquals("A,B,,D => A, B and in range", 2, hits.length());
- searcher.close();
reader.close();
addDoc("C");
reader = IndexReader.open(dir);
@@ -349,7 +336,6 @@ public class TestTermRangeQuery extends LuceneTestCase {
assertEquals("C added => A,B,,C in range", 4, numHits);
// until Lucene-38 is fixed, use this assert
//assertEquals("C added => A,B,,C in range", 3, hits.length());
- searcher.close();
reader.close();
}
}
diff --git a/lucene/src/test/org/apache/lucene/search/TestTermScorer.java b/lucene/src/test/org/apache/lucene/search/TestTermScorer.java
index d8845b0ccbb..34930795e81 100644
--- a/lucene/src/test/org/apache/lucene/search/TestTermScorer.java
+++ b/lucene/src/test/org/apache/lucene/search/TestTermScorer.java
@@ -65,7 +65,6 @@ public class TestTermScorer extends LuceneTestCase {
@Override
public void tearDown() throws Exception {
- indexSearcher.close();
indexReader.close();
directory.close();
super.tearDown();
diff --git a/lucene/src/test/org/apache/lucene/search/TestTermVectors.java b/lucene/src/test/org/apache/lucene/search/TestTermVectors.java
index 68dabea7c75..e35e688b460 100644
--- a/lucene/src/test/org/apache/lucene/search/TestTermVectors.java
+++ b/lucene/src/test/org/apache/lucene/search/TestTermVectors.java
@@ -79,7 +79,6 @@ public class TestTermVectors extends LuceneTestCase {
@Override
public void tearDown() throws Exception {
- searcher.close();
reader.close();
directory.close();
super.tearDown();
diff --git a/lucene/src/test/org/apache/lucene/search/TestTimeLimitingCollector.java b/lucene/src/test/org/apache/lucene/search/TestTimeLimitingCollector.java
index 38119a244d1..844b4d2d496 100644
--- a/lucene/src/test/org/apache/lucene/search/TestTimeLimitingCollector.java
+++ b/lucene/src/test/org/apache/lucene/search/TestTimeLimitingCollector.java
@@ -107,7 +107,6 @@ public class TestTimeLimitingCollector extends LuceneTestCase {
@Override
public void tearDown() throws Exception {
- searcher.close();
reader.close();
directory.close();
counterThread.stopTimer();
diff --git a/lucene/src/test/org/apache/lucene/search/TestTopDocsCollector.java b/lucene/src/test/org/apache/lucene/search/TestTopDocsCollector.java
index 417d9c09abc..b1be9da8a16 100644
--- a/lucene/src/test/org/apache/lucene/search/TestTopDocsCollector.java
+++ b/lucene/src/test/org/apache/lucene/search/TestTopDocsCollector.java
@@ -98,7 +98,6 @@ public class TestTopDocsCollector extends LuceneTestCase {
IndexSearcher searcher = newSearcher(reader);
TopDocsCollector tdc = new MyTopsDocCollector(numResults);
searcher.search(q, tdc);
- searcher.close();
return tdc;
}
diff --git a/lucene/src/test/org/apache/lucene/search/TestTopDocsMerge.java b/lucene/src/test/org/apache/lucene/search/TestTopDocsMerge.java
index 1b32e76061e..cb1ca7315d0 100644
--- a/lucene/src/test/org/apache/lucene/search/TestTopDocsMerge.java
+++ b/lucene/src/test/org/apache/lucene/search/TestTopDocsMerge.java
@@ -238,7 +238,6 @@ public class TestTopDocsMerge extends LuceneTestCase {
_TestUtil.assertEquals(topHits, mergedHits);
}
- searcher.close();
reader.close();
dir.close();
}
diff --git a/lucene/src/test/org/apache/lucene/search/TestTopScoreDocCollector.java b/lucene/src/test/org/apache/lucene/search/TestTopScoreDocCollector.java
index 102dce579e3..c270cd5adf9 100644
--- a/lucene/src/test/org/apache/lucene/search/TestTopScoreDocCollector.java
+++ b/lucene/src/test/org/apache/lucene/search/TestTopScoreDocCollector.java
@@ -61,7 +61,6 @@ public class TestTopScoreDocCollector extends LuceneTestCase {
}
}
writer.close();
- searcher.close();
reader.close();
dir.close();
}
diff --git a/lucene/src/test/org/apache/lucene/search/TestWildcard.java b/lucene/src/test/org/apache/lucene/search/TestWildcard.java
index 635e72aac02..da24e4ded1f 100644
--- a/lucene/src/test/org/apache/lucene/search/TestWildcard.java
+++ b/lucene/src/test/org/apache/lucene/search/TestWildcard.java
@@ -97,7 +97,6 @@ public class TestWildcard
q = searcher.rewrite(wq);
assertTrue(q instanceof ConstantScoreQuery);
assertEquals(q.getBoost(), wq.getBoost(), 0.1);
- searcher.close();
reader.close();
indexStore.close();
}
@@ -116,7 +115,6 @@ public class TestWildcard
Query q = searcher.rewrite(wq);
assertTrue(q instanceof BooleanQuery);
assertEquals(0, ((BooleanQuery) q).clauses().size());
- searcher.close();
reader.close();
indexStore.close();
}
@@ -140,7 +138,6 @@ public class TestWildcard
assertMatches(searcher, wq, 2);
assertFalse(wq.getTermsEnum(terms) instanceof PrefixTermsEnum);
assertFalse(wq.getTermsEnum(terms).getClass().getSimpleName().contains("AutomatonTermsEnum"));
- searcher.close();
reader.close();
indexStore.close();
}
@@ -181,7 +178,6 @@ public class TestWildcard
assertMatches(searcher, new WildcardQuery(new Term("body", "*tall")), 0);
assertMatches(searcher, new WildcardQuery(new Term("body", "*tal")), 1);
assertMatches(searcher, new WildcardQuery(new Term("body", "*tal*")), 2);
- searcher.close();
reader.close();
indexStore.close();
}
@@ -210,7 +206,6 @@ public class TestWildcard
assertMatches(searcher, query4, 3);
assertMatches(searcher, query5, 0);
assertMatches(searcher, query6, 1); // Query: 'meta??' matches 'metals' not 'metal'
- searcher.close();
reader.close();
indexStore.close();
}
@@ -244,7 +239,6 @@ public class TestWildcard
WildcardQuery atEnd = new WildcardQuery(new Term("field", "foo\\"));
assertMatches(searcher, atEnd, 1);
- searcher.close();
reader.close();
indexStore.close();
}
@@ -399,7 +393,6 @@ public class TestWildcard
}
}
- searcher.close();
reader.close();
dir.close();
}
diff --git a/lucene/src/test/org/apache/lucene/search/TestWildcardRandom.java b/lucene/src/test/org/apache/lucene/search/TestWildcardRandom.java
index f4c6e437391..d7a5a9c9e79 100644
--- a/lucene/src/test/org/apache/lucene/search/TestWildcardRandom.java
+++ b/lucene/src/test/org/apache/lucene/search/TestWildcardRandom.java
@@ -100,7 +100,6 @@ public class TestWildcardRandom extends LuceneTestCase {
@Override
public void tearDown() throws Exception {
- searcher.close();
reader.close();
dir.close();
super.tearDown();
diff --git a/lucene/src/test/org/apache/lucene/search/payloads/TestPayloadNearQuery.java b/lucene/src/test/org/apache/lucene/search/payloads/TestPayloadNearQuery.java
index 009b81574af..643952c0a82 100644
--- a/lucene/src/test/org/apache/lucene/search/payloads/TestPayloadNearQuery.java
+++ b/lucene/src/test/org/apache/lucene/search/payloads/TestPayloadNearQuery.java
@@ -129,7 +129,6 @@ public class TestPayloadNearQuery extends LuceneTestCase {
@AfterClass
public static void afterClass() throws Exception {
- searcher.close();
searcher = null;
reader.close();
reader = null;
diff --git a/lucene/src/test/org/apache/lucene/search/payloads/TestPayloadTermQuery.java b/lucene/src/test/org/apache/lucene/search/payloads/TestPayloadTermQuery.java
index 331f82f9952..f8940fbe317 100644
--- a/lucene/src/test/org/apache/lucene/search/payloads/TestPayloadTermQuery.java
+++ b/lucene/src/test/org/apache/lucene/search/payloads/TestPayloadTermQuery.java
@@ -141,7 +141,6 @@ public class TestPayloadTermQuery extends LuceneTestCase {
@AfterClass
public static void afterClass() throws Exception {
- searcher.close();
searcher = null;
reader.close();
reader = null;
@@ -271,7 +270,6 @@ public class TestPayloadTermQuery extends LuceneTestCase {
while (spans.next()) {
count++;
}
- theSearcher.close();
reader.close();
}
diff --git a/lucene/src/test/org/apache/lucene/search/similarities/TestSimilarity2.java b/lucene/src/test/org/apache/lucene/search/similarities/TestSimilarity2.java
index ffa9308e9dd..7fcf89e11c0 100644
--- a/lucene/src/test/org/apache/lucene/search/similarities/TestSimilarity2.java
+++ b/lucene/src/test/org/apache/lucene/search/similarities/TestSimilarity2.java
@@ -91,7 +91,6 @@ public class TestSimilarity2 extends LuceneTestCase {
is.setSimilarityProvider(simProvider);
assertEquals(0, is.search(new TermQuery(new Term("foo", "bar")), 10).totalHits);
}
- is.close();
ir.close();
dir.close();
}
@@ -114,7 +113,6 @@ public class TestSimilarity2 extends LuceneTestCase {
query.add(new TermQuery(new Term("bar", "baz")), BooleanClause.Occur.SHOULD);
assertEquals(1, is.search(query, 10).totalHits);
}
- is.close();
ir.close();
dir.close();
}
@@ -137,7 +135,6 @@ public class TestSimilarity2 extends LuceneTestCase {
query.add(new TermQuery(new Term("foo", "baz")), BooleanClause.Occur.SHOULD);
assertEquals(1, is.search(query, 10).totalHits);
}
- is.close();
ir.close();
dir.close();
}
@@ -162,7 +159,6 @@ public class TestSimilarity2 extends LuceneTestCase {
query.add(new TermQuery(new Term("foo", "bar")), BooleanClause.Occur.SHOULD);
assertEquals(1, is.search(query, 10).totalHits);
}
- is.close();
ir.close();
dir.close();
}
@@ -188,7 +184,6 @@ public class TestSimilarity2 extends LuceneTestCase {
query.add(new TermQuery(new Term("foo", "bar")), BooleanClause.Occur.SHOULD);
assertEquals(1, is.search(query, 10).totalHits);
}
- is.close();
ir.close();
dir.close();
}
@@ -215,7 +210,6 @@ public class TestSimilarity2 extends LuceneTestCase {
query.add(new TermQuery(new Term("foo", "bar")), BooleanClause.Occur.SHOULD);
assertEquals(1, is.search(query, 10).totalHits);
}
- is.close();
ir.close();
dir.close();
}
@@ -247,7 +241,6 @@ public class TestSimilarity2 extends LuceneTestCase {
assertTrue(score >= 0.0f);
assertFalse("inf score for " + simProvider, Float.isInfinite(score));
}
- is.close();
ir.close();
dir.close();
}
diff --git a/lucene/src/test/org/apache/lucene/search/similarities/TestSimilarityBase.java b/lucene/src/test/org/apache/lucene/search/similarities/TestSimilarityBase.java
index 31e2d7d1620..d3fc27953ba 100644
--- a/lucene/src/test/org/apache/lucene/search/similarities/TestSimilarityBase.java
+++ b/lucene/src/test/org/apache/lucene/search/similarities/TestSimilarityBase.java
@@ -577,7 +577,6 @@ public class TestSimilarityBase extends LuceneTestCase {
@Override
public void tearDown() throws Exception {
- searcher.close();
reader.close();
dir.close();
super.tearDown();
diff --git a/lucene/src/test/org/apache/lucene/search/spans/TestBasics.java b/lucene/src/test/org/apache/lucene/search/spans/TestBasics.java
index a364135e0f5..58ff1419489 100644
--- a/lucene/src/test/org/apache/lucene/search/spans/TestBasics.java
+++ b/lucene/src/test/org/apache/lucene/search/spans/TestBasics.java
@@ -125,7 +125,6 @@ public class TestBasics extends LuceneTestCase {
@AfterClass
public static void afterClass() throws Exception {
- searcher.close();
reader.close();
directory.close();
searcher = null;
diff --git a/lucene/src/test/org/apache/lucene/search/spans/TestFieldMaskingSpanQuery.java b/lucene/src/test/org/apache/lucene/search/spans/TestFieldMaskingSpanQuery.java
index fa4c3e368e3..35c28e7ebf9 100644
--- a/lucene/src/test/org/apache/lucene/search/spans/TestFieldMaskingSpanQuery.java
+++ b/lucene/src/test/org/apache/lucene/search/spans/TestFieldMaskingSpanQuery.java
@@ -119,7 +119,6 @@ public class TestFieldMaskingSpanQuery extends LuceneTestCase {
@AfterClass
public static void afterClass() throws Exception {
- searcher.close();
searcher = null;
reader.close();
reader = null;
diff --git a/lucene/src/test/org/apache/lucene/search/spans/TestNearSpansOrdered.java b/lucene/src/test/org/apache/lucene/search/spans/TestNearSpansOrdered.java
index dc2e381cdf4..d0a2169b1e6 100644
--- a/lucene/src/test/org/apache/lucene/search/spans/TestNearSpansOrdered.java
+++ b/lucene/src/test/org/apache/lucene/search/spans/TestNearSpansOrdered.java
@@ -43,7 +43,6 @@ public class TestNearSpansOrdered extends LuceneTestCase {
@Override
public void tearDown() throws Exception {
- searcher.close();
reader.close();
directory.close();
super.tearDown();
diff --git a/lucene/src/test/org/apache/lucene/search/spans/TestPayloadSpans.java b/lucene/src/test/org/apache/lucene/search/spans/TestPayloadSpans.java
index 321e6fc6d79..47934fa0f63 100644
--- a/lucene/src/test/org/apache/lucene/search/spans/TestPayloadSpans.java
+++ b/lucene/src/test/org/apache/lucene/search/spans/TestPayloadSpans.java
@@ -174,7 +174,6 @@ public class TestPayloadSpans extends LuceneTestCase {
spans = MultiSpansWrapper.wrap(searcher.getTopReaderContext(), nestedSpanNearQuery);
assertTrue("spans is null and it shouldn't be", spans != null);
checkSpans(spans, 2, new int[]{3,3});
- searcher.close();
closeIndexReader.close();
directory.close();
}
@@ -207,7 +206,6 @@ public class TestPayloadSpans extends LuceneTestCase {
assertTrue("spans is null and it shouldn't be", spans != null);
checkSpans(spans, 1, new int[]{3});
- searcher.close();
closeIndexReader.close();
directory.close();
}
@@ -245,7 +243,6 @@ public class TestPayloadSpans extends LuceneTestCase {
spans = MultiSpansWrapper.wrap(searcher.getTopReaderContext(), nestedSpanNearQuery);
assertTrue("spans is null and it shouldn't be", spans != null);
checkSpans(spans, 2, new int[]{8, 8});
- searcher.close();
closeIndexReader.close();
directory.close();
}
@@ -284,7 +281,6 @@ public class TestPayloadSpans extends LuceneTestCase {
assertEquals(2, payloadSet.size());
assertTrue(payloadSet.contains("a:Noise:10"));
assertTrue(payloadSet.contains("k:Noise:11"));
- is.close();
reader.close();
directory.close();
}
@@ -321,7 +317,6 @@ public class TestPayloadSpans extends LuceneTestCase {
assertEquals(2, payloadSet.size());
assertTrue(payloadSet.contains("a:Noise:10"));
assertTrue(payloadSet.contains("k:Noise:11"));
- is.close();
reader.close();
directory.close();
}
@@ -364,7 +359,6 @@ public class TestPayloadSpans extends LuceneTestCase {
}
assertTrue(payloadSet.contains("a:Noise:10"));
assertTrue(payloadSet.contains("k:Noise:11"));
- is.close();
reader.close();
directory.close();
}
@@ -391,7 +385,6 @@ public class TestPayloadSpans extends LuceneTestCase {
if(VERBOSE)
System.out.println(new String(bytes));
}
- searcher.close();
reader.close();
directory.close();
}
diff --git a/lucene/src/test/org/apache/lucene/search/spans/TestSpanFirstQuery.java b/lucene/src/test/org/apache/lucene/search/spans/TestSpanFirstQuery.java
index 981f61ba3fd..5622569e29f 100644
--- a/lucene/src/test/org/apache/lucene/search/spans/TestSpanFirstQuery.java
+++ b/lucene/src/test/org/apache/lucene/search/spans/TestSpanFirstQuery.java
@@ -60,7 +60,6 @@ public class TestSpanFirstQuery extends LuceneTestCase {
assertEquals(1, searcher.search(sfq, 10).totalHits);
writer.close();
- searcher.close();
reader.close();
dir.close();
}
diff --git a/lucene/src/test/org/apache/lucene/search/spans/TestSpanMultiTermQueryWrapper.java b/lucene/src/test/org/apache/lucene/search/spans/TestSpanMultiTermQueryWrapper.java
index 1db489897ff..02cc8985035 100644
--- a/lucene/src/test/org/apache/lucene/search/spans/TestSpanMultiTermQueryWrapper.java
+++ b/lucene/src/test/org/apache/lucene/search/spans/TestSpanMultiTermQueryWrapper.java
@@ -59,7 +59,6 @@ public class TestSpanMultiTermQueryWrapper extends LuceneTestCase {
@Override
public void tearDown() throws Exception {
- searcher.close();
reader.close();
directory.close();
super.tearDown();
diff --git a/lucene/src/test/org/apache/lucene/search/spans/TestSpans.java b/lucene/src/test/org/apache/lucene/search/spans/TestSpans.java
index ceaeb39e666..f36f7589f40 100644
--- a/lucene/src/test/org/apache/lucene/search/spans/TestSpans.java
+++ b/lucene/src/test/org/apache/lucene/search/spans/TestSpans.java
@@ -68,7 +68,6 @@ public class TestSpans extends LuceneTestCase {
@Override
public void tearDown() throws Exception {
- searcher.close();
reader.close();
directory.close();
super.tearDown();
@@ -505,7 +504,6 @@ public class TestSpans extends LuceneTestCase {
searcher.search(createSpan(0, true,
new SpanQuery[] {createSpan(4, false, "chased", "cat"),
createSpan("ate")}), 10).totalHits);
- searcher.close();
reader.close();
dir.close();
}
diff --git a/lucene/src/test/org/apache/lucene/search/spans/TestSpansAdvanced.java b/lucene/src/test/org/apache/lucene/search/spans/TestSpansAdvanced.java
index 6e18cf62c9e..b044c72392b 100644
--- a/lucene/src/test/org/apache/lucene/search/spans/TestSpansAdvanced.java
+++ b/lucene/src/test/org/apache/lucene/search/spans/TestSpansAdvanced.java
@@ -74,7 +74,6 @@ public class TestSpansAdvanced extends LuceneTestCase {
@Override
public void tearDown() throws Exception {
- searcher.close();
reader.close();
mDirectory.close();
mDirectory = null;
diff --git a/lucene/src/test/org/apache/lucene/search/spans/TestSpansAdvanced2.java b/lucene/src/test/org/apache/lucene/search/spans/TestSpansAdvanced2.java
index 9c18017028d..7607dfbb128 100644
--- a/lucene/src/test/org/apache/lucene/search/spans/TestSpansAdvanced2.java
+++ b/lucene/src/test/org/apache/lucene/search/spans/TestSpansAdvanced2.java
@@ -65,7 +65,6 @@ public class TestSpansAdvanced2 extends TestSpansAdvanced {
@Override
public void tearDown() throws Exception {
- searcher2.close();
reader2.close();
super.tearDown();
}
diff --git a/lucene/src/test/org/apache/lucene/store/TestBufferedIndexInput.java b/lucene/src/test/org/apache/lucene/store/TestBufferedIndexInput.java
index f40d8c3fefb..2622e9332e9 100755
--- a/lucene/src/test/org/apache/lucene/store/TestBufferedIndexInput.java
+++ b/lucene/src/test/org/apache/lucene/store/TestBufferedIndexInput.java
@@ -274,7 +274,6 @@ public class TestBufferedIndexInput extends LuceneTestCase {
assertEquals(36, hits.length);
reader.close();
- searcher.close();
dir.tweakBufferSizes();
writer.deleteDocuments(new Term("id", "4"));
@@ -292,7 +291,6 @@ public class TestBufferedIndexInput extends LuceneTestCase {
dir.tweakBufferSizes();
assertEquals(35, hits.length);
writer.close();
- searcher.close();
reader.close();
} finally {
_TestUtil.rmDir(indexDir);
diff --git a/lucene/src/test/org/apache/lucene/store/TestLockFactory.java b/lucene/src/test/org/apache/lucene/store/TestLockFactory.java
index 13ef4774628..250aa8d5ba1 100755
--- a/lucene/src/test/org/apache/lucene/store/TestLockFactory.java
+++ b/lucene/src/test/org/apache/lucene/store/TestLockFactory.java
@@ -363,7 +363,6 @@ public class TestLockFactory extends LuceneTestCase {
}
// System.out.println(hits.length() + " total results");
try {
- searcher.close();
reader.close();
} catch (IOException e) {
hitException = true;
diff --git a/lucene/src/test/org/apache/lucene/store/TestRAMDirectory.java b/lucene/src/test/org/apache/lucene/store/TestRAMDirectory.java
index 82ecc24d249..a5b99c2f444 100644
--- a/lucene/src/test/org/apache/lucene/store/TestRAMDirectory.java
+++ b/lucene/src/test/org/apache/lucene/store/TestRAMDirectory.java
@@ -90,7 +90,6 @@ public class TestRAMDirectory extends LuceneTestCase {
// cleanup
reader.close();
- searcher.close();
}
private final int numThreads = 10;
diff --git a/lucene/src/test/org/apache/lucene/store/TestWindowsMMap.java b/lucene/src/test/org/apache/lucene/store/TestWindowsMMap.java
index 25b4550186e..e130be94743 100644
--- a/lucene/src/test/org/apache/lucene/store/TestWindowsMMap.java
+++ b/lucene/src/test/org/apache/lucene/store/TestWindowsMMap.java
@@ -90,7 +90,6 @@ public class TestWindowsMMap extends LuceneTestCase {
writer.addDocument(doc);
}
- searcher.close();
reader.close();
writer.close();
rmDir(dirPath);
diff --git a/modules/analysis/common/src/test/org/apache/lucene/analysis/core/TestKeywordAnalyzer.java b/modules/analysis/common/src/test/org/apache/lucene/analysis/core/TestKeywordAnalyzer.java
index 2f14effcafd..5f9f656641f 100644
--- a/modules/analysis/common/src/test/org/apache/lucene/analysis/core/TestKeywordAnalyzer.java
+++ b/modules/analysis/common/src/test/org/apache/lucene/analysis/core/TestKeywordAnalyzer.java
@@ -63,7 +63,6 @@ public class TestKeywordAnalyzer extends BaseTokenStreamTestCase {
@Override
public void tearDown() throws Exception {
- searcher.close();
reader.close();
directory.close();
super.tearDown();
diff --git a/modules/analysis/common/src/test/org/apache/lucene/analysis/shingle/ShingleAnalyzerWrapperTest.java b/modules/analysis/common/src/test/org/apache/lucene/analysis/shingle/ShingleAnalyzerWrapperTest.java
index f8b8e377538..a3c4878a6a6 100644
--- a/modules/analysis/common/src/test/org/apache/lucene/analysis/shingle/ShingleAnalyzerWrapperTest.java
+++ b/modules/analysis/common/src/test/org/apache/lucene/analysis/shingle/ShingleAnalyzerWrapperTest.java
@@ -80,7 +80,6 @@ public class ShingleAnalyzerWrapperTest extends BaseTokenStreamTestCase {
@Override
public void tearDown() throws Exception {
- searcher.close();
reader.close();
directory.close();
super.tearDown();
diff --git a/modules/benchmark/src/java/org/apache/lucene/benchmark/byTask/PerfRunData.java b/modules/benchmark/src/java/org/apache/lucene/benchmark/byTask/PerfRunData.java
index ff4bd5b2bb0..a190ce671bd 100644
--- a/modules/benchmark/src/java/org/apache/lucene/benchmark/byTask/PerfRunData.java
+++ b/modules/benchmark/src/java/org/apache/lucene/benchmark/byTask/PerfRunData.java
@@ -126,7 +126,7 @@ public class PerfRunData implements Closeable {
}
public void close() throws IOException {
- IOUtils.close(indexWriter, indexReader, indexSearcher, directory,
+ IOUtils.close(indexWriter, indexReader, directory,
taxonomyWriter, taxonomyReader, taxonomyDir,
docMaker, facetSource);
}
diff --git a/modules/benchmark/src/java/org/apache/lucene/benchmark/byTask/tasks/ReadTask.java b/modules/benchmark/src/java/org/apache/lucene/benchmark/byTask/tasks/ReadTask.java
index 3be12b7b15d..93bcb95fcf8 100644
--- a/modules/benchmark/src/java/org/apache/lucene/benchmark/byTask/tasks/ReadTask.java
+++ b/modules/benchmark/src/java/org/apache/lucene/benchmark/byTask/tasks/ReadTask.java
@@ -179,7 +179,6 @@ public abstract class ReadTask extends PerfTask {
}
if (closeSearcher) {
- searcher.close();
reader.close();
} else {
// Release our +1 ref from above
diff --git a/modules/benchmark/src/java/org/apache/lucene/benchmark/quality/trec/QueryDriver.java b/modules/benchmark/src/java/org/apache/lucene/benchmark/quality/trec/QueryDriver.java
index a3b40596f52..aacdf26be40 100644
--- a/modules/benchmark/src/java/org/apache/lucene/benchmark/quality/trec/QueryDriver.java
+++ b/modules/benchmark/src/java/org/apache/lucene/benchmark/quality/trec/QueryDriver.java
@@ -88,7 +88,6 @@ public class QueryDriver {
// print an avarage sum of the results
QualityStats avg = QualityStats.average(stats);
avg.log("SUMMARY", 2, logger, " ");
- searcher.close();
reader.close();
dir.close();
}
diff --git a/modules/benchmark/src/test/org/apache/lucene/benchmark/byTask/feeds/DocMakerTest.java b/modules/benchmark/src/test/org/apache/lucene/benchmark/byTask/feeds/DocMakerTest.java
index cd6aba78f47..cfd1da7431e 100644
--- a/modules/benchmark/src/test/org/apache/lucene/benchmark/byTask/feeds/DocMakerTest.java
+++ b/modules/benchmark/src/test/org/apache/lucene/benchmark/byTask/feeds/DocMakerTest.java
@@ -92,7 +92,6 @@ public class DocMakerTest extends BenchmarkTestCase {
IndexSearcher searcher = new IndexSearcher(reader);
TopDocs td = searcher.search(new TermQuery(new Term("key", "value")), 10);
assertEquals(numExpectedResults, td.totalHits);
- searcher.close();
reader.close();
}
diff --git a/modules/benchmark/src/test/org/apache/lucene/benchmark/byTask/feeds/LineDocSourceTest.java b/modules/benchmark/src/test/org/apache/lucene/benchmark/byTask/feeds/LineDocSourceTest.java
index ac172dcce2b..ffe4ad34f85 100644
--- a/modules/benchmark/src/test/org/apache/lucene/benchmark/byTask/feeds/LineDocSourceTest.java
+++ b/modules/benchmark/src/test/org/apache/lucene/benchmark/byTask/feeds/LineDocSourceTest.java
@@ -160,7 +160,7 @@ public class LineDocSourceTest extends BenchmarkTestCase {
}
assertEquals("Wrong field value", storedField, searcher.doc(0).get(storedField));
} finally {
- IOUtils.close(searcher, reader, runData);
+ IOUtils.close(reader, runData);
}
}
diff --git a/modules/benchmark/src/test/org/apache/lucene/benchmark/quality/TestQualityRun.java b/modules/benchmark/src/test/org/apache/lucene/benchmark/quality/TestQualityRun.java
index 080d52507f7..fffeb35b492 100644
--- a/modules/benchmark/src/test/org/apache/lucene/benchmark/quality/TestQualityRun.java
+++ b/modules/benchmark/src/test/org/apache/lucene/benchmark/quality/TestQualityRun.java
@@ -135,7 +135,6 @@ public class TestQualityRun extends BenchmarkTestCase {
assertTrue("avg p_at_"+j+" should be hurt: "+avg.getPrecisionAt(j), 1.0 > avg.getPrecisionAt(j));
}
- searcher.close();
reader.close();
dir.close();
}
diff --git a/modules/facet/src/test/org/apache/lucene/facet/FacetTestBase.java b/modules/facet/src/test/org/apache/lucene/facet/FacetTestBase.java
index 8afadb67a1e..b5d5b545116 100644
--- a/modules/facet/src/test/org/apache/lucene/facet/FacetTestBase.java
+++ b/modules/facet/src/test/org/apache/lucene/facet/FacetTestBase.java
@@ -231,7 +231,7 @@ public abstract class FacetTestBase extends LuceneTestCase {
/** Close all indexes */
protected void closeAll() throws Exception {
// close and nullify everything
- IOUtils.close(taxoReader, indexReader, searcher);
+ IOUtils.close(taxoReader, indexReader);
taxoReader = null;
indexReader = null;
searcher = null;
diff --git a/modules/facet/src/test/org/apache/lucene/facet/FacetTestUtils.java b/modules/facet/src/test/org/apache/lucene/facet/FacetTestUtils.java
index 1ef82eea659..26fac846398 100644
--- a/modules/facet/src/test/org/apache/lucene/facet/FacetTestUtils.java
+++ b/modules/facet/src/test/org/apache/lucene/facet/FacetTestUtils.java
@@ -138,7 +138,6 @@ public class FacetTestUtils {
public IndexSearcher indexSearcher;
public void close() throws IOException {
- indexSearcher.close();
indexReader.close();
taxReader.close();
}
diff --git a/modules/facet/src/test/org/apache/lucene/facet/search/DrillDownTest.java b/modules/facet/src/test/org/apache/lucene/facet/search/DrillDownTest.java
index 2cfa4387ac0..beba5e077dc 100644
--- a/modules/facet/src/test/org/apache/lucene/facet/search/DrillDownTest.java
+++ b/modules/facet/src/test/org/apache/lucene/facet/search/DrillDownTest.java
@@ -149,8 +149,6 @@ public class DrillDownTest extends LuceneTestCase {
Query q4 = DrillDown.query(defaultParams, fooQuery, new CategoryPath("b"));
docs = searcher.search(q4, 100);
assertEquals(10, docs.totalHits);
-
- searcher.close();
}
@Test
@@ -172,8 +170,6 @@ public class DrillDownTest extends LuceneTestCase {
Query q4 = DrillDown.query(fooQuery, new CategoryPath("b"));
docs = searcher.search(q4, 100);
assertEquals(10, docs.totalHits);
-
- searcher.close();
}
@AfterClass
diff --git a/modules/facet/src/test/org/apache/lucene/facet/search/TestMultipleCategoryLists.java b/modules/facet/src/test/org/apache/lucene/facet/search/TestMultipleCategoryLists.java
index 7ddaec7b2cc..b3927832a7c 100644
--- a/modules/facet/src/test/org/apache/lucene/facet/search/TestMultipleCategoryLists.java
+++ b/modules/facet/src/test/org/apache/lucene/facet/search/TestMultipleCategoryLists.java
@@ -94,7 +94,6 @@ public class TestMultipleCategoryLists extends LuceneTestCase {
tr.close();
ir.close();
- searcher.close();
iw.close();
tw.close();
IOUtils.close(dirs[0]);
@@ -135,7 +134,6 @@ public class TestMultipleCategoryLists extends LuceneTestCase {
tr.close();
ir.close();
- searcher.close();
iw.close();
tw.close();
IOUtils.close(dirs[0]);
@@ -179,7 +177,6 @@ public class TestMultipleCategoryLists extends LuceneTestCase {
tr.close();
ir.close();
- searcher.close();
iw.close();
tw.close();
IOUtils.close(dirs[0]);
@@ -225,7 +222,6 @@ public class TestMultipleCategoryLists extends LuceneTestCase {
assertPostingListExists("$composers", "Composers", ir);
tr.close();
ir.close();
- searcher.close();
iw.close();
tw.close();
IOUtils.close(dirs[0]);
@@ -270,7 +266,6 @@ public class TestMultipleCategoryLists extends LuceneTestCase {
tr.close();
ir.close();
- searcher.close();
iw.close();
tw.close();
IOUtils.close(dirs[0]);
diff --git a/modules/facet/src/test/org/apache/lucene/facet/search/association/AssociationsFacetRequestTest.java b/modules/facet/src/test/org/apache/lucene/facet/search/association/AssociationsFacetRequestTest.java
index 11cdeb1a874..08d63d264aa 100644
--- a/modules/facet/src/test/org/apache/lucene/facet/search/association/AssociationsFacetRequestTest.java
+++ b/modules/facet/src/test/org/apache/lucene/facet/search/association/AssociationsFacetRequestTest.java
@@ -126,7 +126,6 @@ public class AssociationsFacetRequestTest extends LuceneTestCase {
assertEquals("Wrong count for category 'a'!",200, (int) res.get(0).getFacetResultNode().getValue());
assertEquals("Wrong count for category 'b'!",150, (int) res.get(1).getFacetResultNode().getValue());
- searcher.close();
taxo.close();
}
@@ -152,7 +151,6 @@ public class AssociationsFacetRequestTest extends LuceneTestCase {
assertEquals("Wrong count for category 'a'!",50f, (float) res.get(0).getFacetResultNode().getValue(), 0.00001);
assertEquals("Wrong count for category 'b'!",10f, (float) res.get(1).getFacetResultNode().getValue(), 0.00001);
- searcher.close();
taxo.close();
}
@@ -182,7 +180,6 @@ public class AssociationsFacetRequestTest extends LuceneTestCase {
} catch (RuntimeException e) {
// ok - expected
}
- searcher.close();
taxo.close();
}
diff --git a/modules/facet/src/test/org/apache/lucene/facet/util/TestScoredDocIDsUtils.java b/modules/facet/src/test/org/apache/lucene/facet/util/TestScoredDocIDsUtils.java
index a07bfedd523..2a0bc7ab68b 100644
--- a/modules/facet/src/test/org/apache/lucene/facet/util/TestScoredDocIDsUtils.java
+++ b/modules/facet/src/test/org/apache/lucene/facet/util/TestScoredDocIDsUtils.java
@@ -144,7 +144,6 @@ public class TestScoredDocIDsUtils extends LuceneTestCase {
Query q = new TermQuery(new Term(DocumentFactory.field, DocumentFactory.alphaTxt));
IndexSearcher searcher = newSearcher(reader);
searcher.search(q, collector);
- searcher.close();
ScoredDocIDs scoredDocIds = collector.getScoredDocIDs();
OpenBitSet resultSet = new OpenBitSetDISI(scoredDocIds.getDocIDs().iterator(), reader.maxDoc());
diff --git a/modules/grouping/src/test/org/apache/lucene/search/grouping/AllGroupHeadsCollectorTest.java b/modules/grouping/src/test/org/apache/lucene/search/grouping/AllGroupHeadsCollectorTest.java
index cbb6f6ba9c2..006e73db1c2 100644
--- a/modules/grouping/src/test/org/apache/lucene/search/grouping/AllGroupHeadsCollectorTest.java
+++ b/modules/grouping/src/test/org/apache/lucene/search/grouping/AllGroupHeadsCollectorTest.java
@@ -364,7 +364,6 @@ public class AllGroupHeadsCollectorTest extends LuceneTestCase {
assertEquals(expectedGroupHeads[i], actualGroupHeads[i]);
}
}
- s.close();
} finally {
FieldCache.DEFAULT.purge(r);
}
diff --git a/modules/grouping/src/test/org/apache/lucene/search/grouping/TestGrouping.java b/modules/grouping/src/test/org/apache/lucene/search/grouping/TestGrouping.java
index 216eea907d9..4d38b52a807 100644
--- a/modules/grouping/src/test/org/apache/lucene/search/grouping/TestGrouping.java
+++ b/modules/grouping/src/test/org/apache/lucene/search/grouping/TestGrouping.java
@@ -1139,8 +1139,6 @@ public class TestGrouping extends LuceneTestCase {
assertEquals(docIDToIDBlocks, expectedGroups, groupsResultBlocks, false, true, true, getScores, false);
assertEquals(docIDToIDBlocks, expectedGroups, topGroupsBlockShards, false, false, fillFields, getScores, false);
}
- s.close();
- sBlocks.close();
} finally {
FieldCache.DEFAULT.purge(r);
if (rBlocks != null) {
diff --git a/modules/join/src/test/org/apache/lucene/search/join/TestBlockJoin.java b/modules/join/src/test/org/apache/lucene/search/join/TestBlockJoin.java
index 667a78531f9..37f55ead4fc 100644
--- a/modules/join/src/test/org/apache/lucene/search/join/TestBlockJoin.java
+++ b/modules/join/src/test/org/apache/lucene/search/join/TestBlockJoin.java
@@ -131,7 +131,6 @@ public class TestBlockJoin extends LuceneTestCase {
Document parentDoc = s.doc(group.groupValue);
assertEquals("Lisa", parentDoc.get("name"));
- s.close();
r.close();
dir.close();
}
@@ -149,7 +148,6 @@ public class TestBlockJoin extends LuceneTestCase {
bq.setBoost(2f); // we boost the BQ
bq.add(q, BooleanClause.Occur.MUST);
s.search(bq, 10);
- s.close();
r.close();
dir.close();
}
@@ -460,9 +458,7 @@ public class TestBlockJoin extends LuceneTestCase {
}
}
- s.close();
r.close();
- joinS.close();
joinR.close();
dir.close();
joinDir.close();
@@ -594,7 +590,6 @@ public class TestBlockJoin extends LuceneTestCase {
assertEquals("Lisa", parentDoc.get("name"));
- s.close();
r.close();
dir.close();
}
@@ -619,7 +614,6 @@ public class TestBlockJoin extends LuceneTestCase {
Weight weight = s.createNormalizedWeight(q);
DocIdSetIterator disi = weight.scorer(ReaderUtil.leaves(s.getIndexReader().getTopReaderContext())[0], true, true, null);
assertEquals(1, disi.advance(1));
- s.close();
r.close();
dir.close();
}
@@ -654,7 +648,6 @@ public class TestBlockJoin extends LuceneTestCase {
Weight weight = s.createNormalizedWeight(q);
DocIdSetIterator disi = weight.scorer(ReaderUtil.leaves(s.getIndexReader().getTopReaderContext())[0], true, true, null);
assertEquals(2, disi.advance(0));
- s.close();
r.close();
dir.close();
}
diff --git a/modules/queries/src/test/org/apache/lucene/queries/ChainedFilterTest.java b/modules/queries/src/test/org/apache/lucene/queries/ChainedFilterTest.java
index 415dbde64fb..3614daf3751 100644
--- a/modules/queries/src/test/org/apache/lucene/queries/ChainedFilterTest.java
+++ b/modules/queries/src/test/org/apache/lucene/queries/ChainedFilterTest.java
@@ -94,7 +94,6 @@ public class ChainedFilterTest extends LuceneTestCase {
@Override
public void tearDown() throws Exception {
- searcher.close();
reader.close();
directory.close();
super.tearDown();
@@ -211,7 +210,6 @@ public class ChainedFilterTest extends LuceneTestCase {
// throws java.lang.ClassCastException: org.apache.lucene.util.OpenBitSet cannot be cast to java.util.BitSet
searcher.search(new MatchAllDocsQuery(), cf, 1);
- searcher.close();
reader.close();
dir.close();
}
diff --git a/modules/queries/src/test/org/apache/lucene/queries/TestCustomScoreQuery.java b/modules/queries/src/test/org/apache/lucene/queries/TestCustomScoreQuery.java
index 3c785c144a3..f4585482ac2 100755
--- a/modules/queries/src/test/org/apache/lucene/queries/TestCustomScoreQuery.java
+++ b/modules/queries/src/test/org/apache/lucene/queries/TestCustomScoreQuery.java
@@ -208,7 +208,6 @@ public class TestCustomScoreQuery extends FunctionTestSetup {
final float score = hits.scoreDocs[i].score;
assertEquals("doc=" + doc, (float) 1+(4*doc) % N_DOCS, score, 0.0001);
}
- s.close();
r.close();
}
@@ -232,7 +231,6 @@ public class TestCustomScoreQuery extends FunctionTestSetup {
assertEquals(s.search(q,1).totalHits, s.search(original,1).totalHits);
assertEquals(s.search(q,1).totalHits, s.search(rewritten,1).totalHits);
- s.close();
r.close();
}
@@ -290,7 +288,6 @@ public class TestCustomScoreQuery extends FunctionTestSetup {
verifyResults(boost, s,
h1, h2CustomNeutral, h3CustomMul, h4CustomAdd, h5CustomMulAdd,
q1, q2CustomNeutral, q3CustomMul, q4CustomAdd, q5CustomMulAdd);
- s.close();
r.close();
}
diff --git a/modules/queries/src/test/org/apache/lucene/queries/function/TestFieldScoreQuery.java b/modules/queries/src/test/org/apache/lucene/queries/function/TestFieldScoreQuery.java
index a24a25cda64..3be1b4b9b63 100755
--- a/modules/queries/src/test/org/apache/lucene/queries/function/TestFieldScoreQuery.java
+++ b/modules/queries/src/test/org/apache/lucene/queries/function/TestFieldScoreQuery.java
@@ -95,7 +95,6 @@ public class TestFieldScoreQuery extends FunctionTestSetup {
assertTrue("res id "+resID+" should be < prev res id "+prevID, resID.compareTo(prevID)<0);
prevID = resID;
}
- s.close();
r.close();
}
@@ -143,7 +142,6 @@ public class TestFieldScoreQuery extends FunctionTestSetup {
float expectedScore = expectedFieldScore(id); // "ID7" --> 7.0
assertEquals("score of " + id + " shuould be " + expectedScore + " != " + score, expectedScore, score, TEST_SCORE_TOLERANCE_DELTA);
}
- s.close();
r.close();
}
diff --git a/modules/queries/src/test/org/apache/lucene/queries/function/TestOrdValues.java b/modules/queries/src/test/org/apache/lucene/queries/function/TestOrdValues.java
index 1cb599fa37c..3c2aeca7004 100644
--- a/modules/queries/src/test/org/apache/lucene/queries/function/TestOrdValues.java
+++ b/modules/queries/src/test/org/apache/lucene/queries/function/TestOrdValues.java
@@ -92,7 +92,6 @@ public class TestOrdValues extends FunctionTestSetup {
}
prevID = resID;
}
- s.close();
r.close();
}
@@ -139,7 +138,6 @@ public class TestOrdValues extends FunctionTestSetup {
: id2String(i + 1); // reverse ==> smaller values first
assertTrue("id of result " + i + " shuould be " + expectedId + " != " + score, expectedId.equals(id));
}
- s.close();
r.close();
}
diff --git a/modules/queries/src/test/org/apache/lucene/queries/mlt/TestMoreLikeThis.java b/modules/queries/src/test/org/apache/lucene/queries/mlt/TestMoreLikeThis.java
index 590c5a2cd28..fe71dffd7d9 100644
--- a/modules/queries/src/test/org/apache/lucene/queries/mlt/TestMoreLikeThis.java
+++ b/modules/queries/src/test/org/apache/lucene/queries/mlt/TestMoreLikeThis.java
@@ -59,7 +59,6 @@ public class TestMoreLikeThis extends LuceneTestCase {
@Override
public void tearDown() throws Exception {
reader.close();
- searcher.close();
directory.close();
super.tearDown();
}
diff --git a/modules/queryparser/src/test/org/apache/lucene/queryparser/classic/TestMultiFieldQueryParser.java b/modules/queryparser/src/test/org/apache/lucene/queryparser/classic/TestMultiFieldQueryParser.java
index 8ab6beb4226..b6de5e39da1 100644
--- a/modules/queryparser/src/test/org/apache/lucene/queryparser/classic/TestMultiFieldQueryParser.java
+++ b/modules/queryparser/src/test/org/apache/lucene/queryparser/classic/TestMultiFieldQueryParser.java
@@ -295,7 +295,6 @@ public class TestMultiFieldQueryParser extends LuceneTestCase {
IndexSearcher is = new IndexSearcher(ir);
ScoreDoc[] hits = is.search(q, null, 1000).scoreDocs;
assertEquals(1, hits.length);
- is.close();
ir.close();
ramDir.close();
}
diff --git a/modules/queryparser/src/test/org/apache/lucene/queryparser/complexPhrase/TestComplexPhraseQuery.java b/modules/queryparser/src/test/org/apache/lucene/queryparser/complexPhrase/TestComplexPhraseQuery.java
index e6b84b5f07b..37109b0f0dc 100644
--- a/modules/queryparser/src/test/org/apache/lucene/queryparser/complexPhrase/TestComplexPhraseQuery.java
+++ b/modules/queryparser/src/test/org/apache/lucene/queryparser/complexPhrase/TestComplexPhraseQuery.java
@@ -128,7 +128,6 @@ public class TestComplexPhraseQuery extends LuceneTestCase {
@Override
public void tearDown() throws Exception {
- searcher.close();
reader.close();
rd.close();
super.tearDown();
diff --git a/modules/queryparser/src/test/org/apache/lucene/queryparser/flexible/standard/TestMultiFieldQPHelper.java b/modules/queryparser/src/test/org/apache/lucene/queryparser/flexible/standard/TestMultiFieldQPHelper.java
index 82e810796e8..67cdabf6dcd 100644
--- a/modules/queryparser/src/test/org/apache/lucene/queryparser/flexible/standard/TestMultiFieldQPHelper.java
+++ b/modules/queryparser/src/test/org/apache/lucene/queryparser/flexible/standard/TestMultiFieldQPHelper.java
@@ -333,7 +333,6 @@ public class TestMultiFieldQPHelper extends LuceneTestCase {
IndexSearcher is = new IndexSearcher(ir);
ScoreDoc[] hits = is.search(q, null, 1000).scoreDocs;
assertEquals(1, hits.length);
- is.close();
ir.close();
ramDir.close();
}
diff --git a/modules/queryparser/src/test/org/apache/lucene/queryparser/flexible/standard/TestNumericQueryParser.java b/modules/queryparser/src/test/org/apache/lucene/queryparser/flexible/standard/TestNumericQueryParser.java
index f7b2bbfc1c0..ccd8a8b084e 100644
--- a/modules/queryparser/src/test/org/apache/lucene/queryparser/flexible/standard/TestNumericQueryParser.java
+++ b/modules/queryparser/src/test/org/apache/lucene/queryparser/flexible/standard/TestNumericQueryParser.java
@@ -488,7 +488,6 @@ public class TestNumericQueryParser extends LuceneTestCase {
@AfterClass
public static void afterClass() throws Exception {
- searcher.close();
searcher = null;
reader.close();
reader = null;
diff --git a/modules/queryparser/src/test/org/apache/lucene/queryparser/flexible/standard/TestQPHelper.java b/modules/queryparser/src/test/org/apache/lucene/queryparser/flexible/standard/TestQPHelper.java
index 55d155b8f40..03ad2c3b1b9 100644
--- a/modules/queryparser/src/test/org/apache/lucene/queryparser/flexible/standard/TestQPHelper.java
+++ b/modules/queryparser/src/test/org/apache/lucene/queryparser/flexible/standard/TestQPHelper.java
@@ -1269,7 +1269,6 @@ public class TestQPHelper extends LuceneTestCase {
Query q = new StandardQueryParser(new CannedAnalyzer()).parse("\"a\"", "field");
assertTrue(q instanceof MultiPhraseQuery);
assertEquals(1, s.search(q, 10).totalHits);
- s.close();
r.close();
w.close();
dir.close();
diff --git a/modules/queryparser/src/test/org/apache/lucene/queryparser/surround/query/BooleanQueryTst.java b/modules/queryparser/src/test/org/apache/lucene/queryparser/surround/query/BooleanQueryTst.java
index 35633b535db..e8cab1481de 100644
--- a/modules/queryparser/src/test/org/apache/lucene/queryparser/surround/query/BooleanQueryTst.java
+++ b/modules/queryparser/src/test/org/apache/lucene/queryparser/surround/query/BooleanQueryTst.java
@@ -127,7 +127,6 @@ public class BooleanQueryTst {
try {
searcher.search(query, tc);
} finally {
- searcher.close();
reader.close();
}
tc.checkNrHits();
diff --git a/modules/queryparser/src/test/org/apache/lucene/queryparser/util/QueryParserTestBase.java b/modules/queryparser/src/test/org/apache/lucene/queryparser/util/QueryParserTestBase.java
index d4cf0350031..9e88d7f5f0c 100644
--- a/modules/queryparser/src/test/org/apache/lucene/queryparser/util/QueryParserTestBase.java
+++ b/modules/queryparser/src/test/org/apache/lucene/queryparser/util/QueryParserTestBase.java
@@ -1095,7 +1095,6 @@ public abstract class QueryParserTestBase extends LuceneTestCase {
QueryParser qp = new QueryParser(TEST_VERSION_CURRENT, "f", a);
Query q = qp.parse("\"wizard of ozzy\"");
assertEquals(1, s.search(q, 1).totalHits);
- s.close();
r.close();
dir.close();
}
diff --git a/modules/queryparser/src/test/org/apache/lucene/queryparser/xml/TestParser.java b/modules/queryparser/src/test/org/apache/lucene/queryparser/xml/TestParser.java
index 26d9414c2f1..7d92978b27c 100644
--- a/modules/queryparser/src/test/org/apache/lucene/queryparser/xml/TestParser.java
+++ b/modules/queryparser/src/test/org/apache/lucene/queryparser/xml/TestParser.java
@@ -84,7 +84,6 @@ public class TestParser extends LuceneTestCase {
@AfterClass
public static void afterClass() throws Exception {
reader.close();
- searcher.close();
dir.close();
reader = null;
searcher = null;
diff --git a/modules/queryparser/src/test/org/apache/lucene/queryparser/xml/TestQueryTemplateManager.java b/modules/queryparser/src/test/org/apache/lucene/queryparser/xml/TestQueryTemplateManager.java
index a9626db6659..cd9c12cce11 100644
--- a/modules/queryparser/src/test/org/apache/lucene/queryparser/xml/TestQueryTemplateManager.java
+++ b/modules/queryparser/src/test/org/apache/lucene/queryparser/xml/TestQueryTemplateManager.java
@@ -159,7 +159,6 @@ public class TestQueryTemplateManager extends LuceneTestCase {
@Override
public void tearDown() throws Exception {
- searcher.close();
reader.close();
dir.close();
super.tearDown();
diff --git a/modules/suggest/src/java/org/apache/lucene/search/spell/SpellChecker.java b/modules/suggest/src/java/org/apache/lucene/search/spell/SpellChecker.java
index 7b84f2337b2..cb4771c8ee8 100755
--- a/modules/suggest/src/java/org/apache/lucene/search/spell/SpellChecker.java
+++ b/modules/suggest/src/java/org/apache/lucene/search/spell/SpellChecker.java
@@ -639,7 +639,6 @@ public class SpellChecker implements java.io.Closeable {
closed = true;
if (searcher != null) {
searcher.getIndexReader().close();
- searcher.close();
}
searcher = null;
}
@@ -655,12 +654,10 @@ public class SpellChecker implements java.io.Closeable {
synchronized (searcherLock) {
if(closed){
indexSearcher.getIndexReader().close();
- indexSearcher.close();
throw new AlreadyClosedException("Spellchecker has been closed");
}
if (searcher != null) {
searcher.getIndexReader().close();
- searcher.close();
}
// set the spellindex in the sync block - ensure consistency.
searcher = indexSearcher;
diff --git a/solr/core/src/java/org/apache/solr/search/SolrIndexSearcher.java b/solr/core/src/java/org/apache/solr/search/SolrIndexSearcher.java
index 250b64b183f..54863cfe220 100644
--- a/solr/core/src/java/org/apache/solr/search/SolrIndexSearcher.java
+++ b/solr/core/src/java/org/apache/solr/search/SolrIndexSearcher.java
@@ -17,6 +17,7 @@
package org.apache.solr.search;
+import java.io.Closeable;
import java.io.IOException;
import java.net.URL;
import java.util.*;
@@ -63,7 +64,7 @@ import org.slf4j.LoggerFactory;
*
* @since solr 0.9
*/
-public class SolrIndexSearcher extends IndexSearcher implements SolrInfoMBean {
+public class SolrIndexSearcher extends IndexSearcher implements Closeable,SolrInfoMBean {
// These should *only* be used for debugging or monitoring purposes
public static final AtomicLong numOpens = new AtomicLong();
@@ -220,7 +221,6 @@ public class SolrIndexSearcher extends IndexSearcher implements SolrInfoMBean {
*
* In particular, the underlying reader and any cache's in use are closed.
*/
- @Override
public void close() throws IOException {
if (cachingEnabled) {
StringBuilder sb = new StringBuilder();
diff --git a/solr/core/src/test/org/apache/solr/handler/TestReplicationHandler.java b/solr/core/src/test/org/apache/solr/handler/TestReplicationHandler.java
index 11343dcac76..90c9dc070f0 100644
--- a/solr/core/src/test/org/apache/solr/handler/TestReplicationHandler.java
+++ b/solr/core/src/test/org/apache/solr/handler/TestReplicationHandler.java
@@ -861,7 +861,6 @@ public class TestReplicationHandler extends SolrTestCaseJ4 {
TopDocs hits = searcher.search(new MatchAllDocsQuery(), 1);
assertEquals(nDocs, hits.totalHits);
reader.close();
- searcher.close();
dir.close();
}
if(snapDir[0].exists()) {
diff --git a/solr/core/src/test/org/apache/solr/search/TestSort.java b/solr/core/src/test/org/apache/solr/search/TestSort.java
index efb281546c9..e66cfd89bea 100755
--- a/solr/core/src/test/org/apache/solr/search/TestSort.java
+++ b/solr/core/src/test/org/apache/solr/search/TestSort.java
@@ -302,7 +302,6 @@ public class TestSort extends SolrTestCaseJ4 {
assertEquals(id, collectedDocs.get(j).doc);
}
}
- searcher.close();
reader.close();
}
dir.close();