You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@lucene.apache.org by jp...@apache.org on 2015/03/04 16:53:21 UTC
svn commit: r1664057 - in /lucene/dev/branches/branch_5x: ./ lucene/
lucene/test-framework/
lucene/test-framework/src/java/org/apache/lucene/util/LuceneTestCase.java
Author: jpountz
Date: Wed Mar 4 15:53:20 2015
New Revision: 1664057
URL: http://svn.apache.org/r1664057
Log:
Fix tests reproducibility.
Some tests instantiate an IndexSearcher in an @BeforeClass method. So we need
to reset the query cache in @BeforeClass too or they would use a shared cache.
Modified:
lucene/dev/branches/branch_5x/ (props changed)
lucene/dev/branches/branch_5x/lucene/ (props changed)
lucene/dev/branches/branch_5x/lucene/test-framework/ (props changed)
lucene/dev/branches/branch_5x/lucene/test-framework/src/java/org/apache/lucene/util/LuceneTestCase.java
Modified: lucene/dev/branches/branch_5x/lucene/test-framework/src/java/org/apache/lucene/util/LuceneTestCase.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/branch_5x/lucene/test-framework/src/java/org/apache/lucene/util/LuceneTestCase.java?rev=1664057&r1=1664056&r2=1664057&view=diff
==============================================================================
--- lucene/dev/branches/branch_5x/lucene/test-framework/src/java/org/apache/lucene/util/LuceneTestCase.java (original)
+++ lucene/dev/branches/branch_5x/lucene/test-framework/src/java/org/apache/lucene/util/LuceneTestCase.java Wed Mar 4 15:53:20 2015
@@ -1652,7 +1652,15 @@ public abstract class LuceneTestCase ext
}
@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 cache
IndexSearcher.setDefaultQueryCache(new LRUQueryCache(10000, 1 << 25));
IndexSearcher.setDefaultQueryCachingPolicy(MAYBE_CACHE_POLICY);
}