lucene-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From mikemcc...@apache.org
Subject svn commit: r1045316 - in /lucene/dev/branches/branch_3x: ./ lucene/ lucene/src/test/org/apache/lucene/index/TestIndexReaderReopen.java solr/
Date Mon, 13 Dec 2010 19:12:31 GMT
Author: mikemccand
Date: Mon Dec 13 19:12:30 2010
New Revision: 1045316

URL: http://svn.apache.org/viewvc?rev=1045316&view=rev
Log:
make test more evil

Modified:
    lucene/dev/branches/branch_3x/   (props changed)
    lucene/dev/branches/branch_3x/lucene/   (props changed)
    lucene/dev/branches/branch_3x/lucene/src/test/org/apache/lucene/index/TestIndexReaderReopen.java
    lucene/dev/branches/branch_3x/solr/   (props changed)

Modified: lucene/dev/branches/branch_3x/lucene/src/test/org/apache/lucene/index/TestIndexReaderReopen.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/branch_3x/lucene/src/test/org/apache/lucene/index/TestIndexReaderReopen.java?rev=1045316&r1=1045315&r2=1045316&view=diff
==============================================================================
--- lucene/dev/branches/branch_3x/lucene/src/test/org/apache/lucene/index/TestIndexReaderReopen.java
(original)
+++ lucene/dev/branches/branch_3x/lucene/src/test/org/apache/lucene/index/TestIndexReaderReopen.java
Mon Dec 13 19:12:30 2010
@@ -22,29 +22,29 @@ import java.io.IOException;
 import java.util.ArrayList;
 import java.util.Collection;
 import java.util.Collections;
+import java.util.HashMap;
 import java.util.HashSet;
-
 import java.util.List;
-import java.util.Random;
 import java.util.Map;
-import java.util.HashMap;
+import java.util.Random;
 import java.util.Set;
 
 import org.apache.lucene.analysis.KeywordAnalyzer;
 import org.apache.lucene.analysis.WhitespaceAnalyzer;
 import org.apache.lucene.analysis.standard.StandardAnalyzer;
 import org.apache.lucene.document.Document;
-import org.apache.lucene.document.Field;
 import org.apache.lucene.document.Field.Index;
 import org.apache.lucene.document.Field.Store;
+import org.apache.lucene.document.Field;
 import org.apache.lucene.index.IndexWriterConfig.OpenMode;
 import org.apache.lucene.search.IndexSearcher;
 import org.apache.lucene.search.ScoreDoc;
 import org.apache.lucene.search.TermQuery;
-import org.apache.lucene.store.Directory;
 import org.apache.lucene.store.AlreadyClosedException;
-import org.apache.lucene.util.LuceneTestCase;
+import org.apache.lucene.store.Directory;
 import org.apache.lucene.util.BitVector;
+import org.apache.lucene.util.LuceneTestCase;
+import org.apache.lucene.util._TestUtil;
 
 public class TestIndexReaderReopen extends LuceneTestCase {
     
@@ -755,7 +755,7 @@ public class TestIndexReaderReopen exten
       
       ReaderThreadTask task;
       
-      if (i < 4 ||( i >=10 && i < 14) || i > 18) {
+      if (i < 4 || (i >=10 && i < 14) || i > 18) {
         task = new ReaderThreadTask() {
           
           @Override
@@ -773,7 +773,6 @@ public class TestIndexReaderReopen exten
                 // not synchronized
                 IndexReader refreshed = r.reopen();
                 
-                
                 IndexSearcher searcher = new IndexSearcher(refreshed);
                 ScoreDoc[] hits = searcher.search(
                     new TermQuery(new Term("field1", "a" + rnd.nextInt(refreshed.maxDoc()))),
@@ -782,19 +781,12 @@ public class TestIndexReaderReopen exten
                   searcher.doc(hits[0].doc);
                 }
                 
-                // r might have changed because this is not a 
-                // synchronized method. However we don't want
-                // to make it synchronized to test 
-                // thread-safety of IndexReader.close().
-                // That's why we add refreshed also to 
-                // readersToClose, because double closing is fine
                 if (refreshed != r) {
                   refreshed.close();
                 }
-                readersToClose.add(refreshed);
               }
               synchronized(this) {
-                wait(1000);
+                wait(_TestUtil.nextInt(random, 1, 100));
               }
             }
           }
@@ -812,12 +804,10 @@ public class TestIndexReaderReopen exten
               }
               
               synchronized(this) {
-                wait(100);
+                wait(_TestUtil.nextInt(random, 1, 100));
               }
             }
-                        
           }
-          
         };
       }
       
@@ -874,7 +864,7 @@ public class TestIndexReaderReopen exten
   }
   
   private abstract static class ReaderThreadTask {
-    protected boolean stopped;
+    protected volatile boolean stopped;
     public void stop() {
       this.stopped = true;
     }



Mime
View raw message