From c197d2d420562d9a641eeea75bd997210fdedda5 Mon Sep 17 00:00:00 2001 From: Michael McCandless Date: Thu, 11 Apr 2013 13:38:33 +0000 Subject: [PATCH] reduce number of fleeting threads created by this test git-svn-id: https://svn.apache.org/repos/asf/lucene/dev/trunk@1466884 13f79535-47bb-0310-9956-ffa450edef68 --- .../org/apache/lucene/index/TestStressNRT.java | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) diff --git a/lucene/core/src/test/org/apache/lucene/index/TestStressNRT.java b/lucene/core/src/test/org/apache/lucene/index/TestStressNRT.java index a9fdb29881d..1af5a43f85d 100644 --- a/lucene/core/src/test/org/apache/lucene/index/TestStressNRT.java +++ b/lucene/core/src/test/org/apache/lucene/index/TestStressNRT.java @@ -298,6 +298,9 @@ public class TestStressNRT extends LuceneTestCase { @Override public void run() { try { + IndexReader lastReader = null; + IndexSearcher lastSearcher = null; + while (operations.decrementAndGet() >= 0) { // bias toward a recently changed doc int id = rand.nextInt(100) < 25 ? lastId : rand.nextInt(ndocs); @@ -318,7 +321,17 @@ public class TestStressNRT extends LuceneTestCase { } // sreq = req("wt","json", "q","id:"+Integer.toString(id), "omitHeader","true"); - IndexSearcher searcher = newSearcher(r); + IndexSearcher searcher; + if (r == lastReader) { + // Just re-use lastSearcher, else + // newSearcher may create too many thread + // pools (ExecutorService): + searcher = lastSearcher; + } else { + searcher = newSearcher(r); + lastReader = r; + lastSearcher = searcher; + } Query q = new TermQuery(new Term("id",Integer.toString(id))); TopDocs results = searcher.search(q, 10);