Apache Lucene open-source search software
Fix tests reproducibility.
Adrien Grand5406a2ae14ab
diff --git a/lucene/test-framework/src/java/org/apache/lucene/util/LuceneTestCase.java b/lucene/test-framework/src/java/org/apache/lucene/util/LuceneTestCase.javaindex 048abb997fe..4f3966a17fa 100644--- a/lucene/test-framework/src/java/org/apache/lucene/util/LuceneTestCase.java+++ b/lucene/test-framework/src/java/org/apache/lucene/util/LuceneTestCase.java@@ -1651,7 +1651,15 @@ public abstract class LuceneTestCase extends Assert {}@Before- public void resetDefaultQueryCache() {+ public void resetTestDefaultQueryCache() {+ // Make sure each test method has its own cache+ resetDefaultQueryCache();+ }++ @BeforeClass+ public static void resetDefaultQueryCache() {+ // we need to reset the query cache in an @BeforeClass so that tests that+ // instantiate an IndexSearcher in an @BeforeClass method use a fresh new cacheIndexSearcher.setDefaultQueryCache(new LRUQueryCache(10000, 1 << 25));IndexSearcher.setDefaultQueryCachingPolicy(MAYBE_CACHE_POLICY);}