You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@lucene.apache.org by ho...@apache.org on 2010/05/01 02:50:25 UTC

svn commit: r939889 - /lucene/dev/trunk/lucene/src/test/org/apache/lucene/util/LuceneTestCaseJ4.java

Author: hossman
Date: Sat May  1 00:50:24 2010
New Revision: 939889

URL: http://svn.apache.org/viewvc?rev=939889&view=rev
Log:
revert the static boolean checkFieldCacheSanity that yonik added for SOLR-1875.  since it's in the base class it's dangerous if some test class sets it to false and never sets it back to true.  added additional comments to where assertSaneFieldCaches is called so that if people run into the same situation yonik did in hte future they'll see how to deal with it (either by refactoring, or by using purgeFieldCache)

Modified:
    lucene/dev/trunk/lucene/src/test/org/apache/lucene/util/LuceneTestCaseJ4.java

Modified: lucene/dev/trunk/lucene/src/test/org/apache/lucene/util/LuceneTestCaseJ4.java
URL: http://svn.apache.org/viewvc/lucene/dev/trunk/lucene/src/test/org/apache/lucene/util/LuceneTestCaseJ4.java?rev=939889&r1=939888&r2=939889&view=diff
==============================================================================
--- lucene/dev/trunk/lucene/src/test/org/apache/lucene/util/LuceneTestCaseJ4.java (original)
+++ lucene/dev/trunk/lucene/src/test/org/apache/lucene/util/LuceneTestCaseJ4.java Sat May  1 00:50:24 2010
@@ -93,8 +93,6 @@ public class LuceneTestCaseJ4 {
    */
   public static final Version TEST_VERSION_CURRENT = Version.LUCENE_31;
 
-  public static boolean checkFieldCacheSanity = true;
-
   /** Create indexes in this directory, optimally use a subdir, named after the test */
   public static final File TEMP_DIR;
   static {
@@ -195,12 +193,19 @@ public class LuceneTestCaseJ4 {
   public void tearDown() throws Exception {
     BooleanQuery.setMaxClauseCount(savedBoolMaxClauseCount);
     try {
-      // this isn't as useful as calling directly from the scope where the
-      // index readers are used, because they could be gc'ed just before
-      // tearDown is called.
+      // calling assertSaneFieldCaches here isn't as useful as having test 
+      // classes call it directly from the scope where the index readers 
+      // are used, because they could be gc'ed just before this tearDown 
+      // method is called.
+      //
       // But it's better then nothing.
-      if (checkFieldCacheSanity)
-        assertSaneFieldCaches(getTestLabel());
+      //
+      // If you are testing functionality that you know for a fact 
+      // "violates" FieldCache sanity, then you should either explicitly 
+      // call purgeFieldCache at the end of your test method, or refactor
+      // your Test class so that the inconsistant FieldCache usages are 
+      // isolated in distinct test methods  
+      assertSaneFieldCaches(getTestLabel());
 
       if (ConcurrentMergeScheduler.anyUnhandledExceptions()) {
         // Clear the failure so that we don't just keep