merge unrelated nightly test bugfixes from LUCENE-6271 branch

git-svn-id: https://svn.apache.org/repos/asf/lucene/dev/trunk@1670529 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
Robert Muir 2015-04-01 00:55:00 +00:00
parent 33fc7b5046
commit 86bea1d123
3 changed files with 16 additions and 9 deletions

View File

@ -28,6 +28,7 @@ import java.util.HashSet;
import java.util.LinkedHashMap; import java.util.LinkedHashMap;
import java.util.List; import java.util.List;
import java.util.Map; import java.util.Map;
import java.util.concurrent.ExecutionException;
import java.util.concurrent.atomic.AtomicBoolean; import java.util.concurrent.atomic.AtomicBoolean;
import java.util.concurrent.atomic.AtomicLong; import java.util.concurrent.atomic.AtomicLong;
import java.util.concurrent.atomic.AtomicReference; import java.util.concurrent.atomic.AtomicReference;
@ -957,12 +958,18 @@ public class TestLRUQueryCache extends LuceneTestCase {
BadQuery query = new BadQuery(); BadQuery query = new BadQuery();
searcher.count(query); searcher.count(query);
query.i[0] += 1; // change the hashCode! query.i[0] += 1; // change the hashCode!
try { try {
// trigger an eviction // trigger an eviction
searcher.count(new MatchAllDocsQuery()); searcher.count(new MatchAllDocsQuery());
fail(); fail();
} catch (ConcurrentModificationException e) { } catch (ConcurrentModificationException e) {
// expected // expected
} catch (RuntimeException e) {
// expected: wrapped when executor is in use
Throwable cause = e.getCause();
assertTrue(cause instanceof ExecutionException);
assertTrue(cause.getCause() instanceof ConcurrentModificationException);
} }
IOUtils.close(w, reader, dir); IOUtils.close(w, reader, dir);

View File

@ -309,7 +309,6 @@ public abstract class ThreadedIndexingAndSearchingTestCase extends LuceneTestCas
doAfterIndexingThreadDone(); doAfterIndexingThreadDone();
} }
}; };
threads[thread].setDaemon(true);
threads[thread].start(); threads[thread].start();
} }
@ -332,7 +331,7 @@ public abstract class ThreadedIndexingAndSearchingTestCase extends LuceneTestCas
if (VERBOSE) { if (VERBOSE) {
System.out.println(Thread.currentThread().getName() + ": launch search thread"); System.out.println(Thread.currentThread().getName() + ": launch search thread");
} }
while (System.currentTimeMillis() < stopTimeMS) { while (System.currentTimeMillis() < stopTimeMS && !failed.get()) {
try { try {
final IndexSearcher s = getCurrentSearcher(); final IndexSearcher s = getCurrentSearcher();
try { try {
@ -399,12 +398,11 @@ public abstract class ThreadedIndexingAndSearchingTestCase extends LuceneTestCas
} }
} }
}; };
searchThreads[thread].setDaemon(true);
searchThreads[thread].start(); searchThreads[thread].start();
} }
for(int thread=0;thread<searchThreads.length;thread++) { for(Thread thread : searchThreads) {
searchThreads[thread].join(); thread.join();
} }
if (VERBOSE) { if (VERBOSE) {
@ -535,8 +533,8 @@ public abstract class ThreadedIndexingAndSearchingTestCase extends LuceneTestCas
System.out.println("TEST: all searching done [" + (System.currentTimeMillis()-t0) + " ms]"); System.out.println("TEST: all searching done [" + (System.currentTimeMillis()-t0) + " ms]");
} }
for(int thread=0;thread<indexThreads.length;thread++) { for(Thread thread : indexThreads) {
indexThreads[thread].join(); thread.join();
} }
if (VERBOSE) { if (VERBOSE) {

View File

@ -146,7 +146,8 @@ public class LineFileDocs implements Closeable {
} }
public synchronized void reset(Random random) throws IOException { public synchronized void reset(Random random) throws IOException {
close(); reader.close();
reader = null;
open(random); open(random);
id.set(0); id.set(0);
} }
@ -215,7 +216,8 @@ public class LineFileDocs implements Closeable {
if (LuceneTestCase.VERBOSE) { if (LuceneTestCase.VERBOSE) {
System.out.println("TEST: LineFileDocs: now rewind file..."); System.out.println("TEST: LineFileDocs: now rewind file...");
} }
close(); reader.close();
reader = null;
open(null); open(null);
line = reader.readLine(); line = reader.readLine();
} }