Index: lucene/src/test/org/apache/lucene/search/TestThreadSafe.java =================================================================== --- lucene/src/test/org/apache/lucene/search/TestThreadSafe.java (revision 1055590) +++ lucene/src/test/org/apache/lucene/search/TestThreadSafe.java (working copy) @@ -27,6 +27,7 @@ import java.util.Random; import java.util.List; +import java.util.concurrent.atomic.AtomicBoolean; import java.io.IOException; public class TestThreadSafe extends LuceneTestCase { @@ -34,16 +35,16 @@ IndexReader ir1; - String failure=null; - - class Thr extends Thread { final int iter; final Random rand; + final AtomicBoolean failed; + // pass in random in case we want to make things reproducable - public Thr(int iter, Random rand) { + public Thr(int iter, Random rand, AtomicBoolean failed) { this.iter = iter; this.rand = rand; + this.failed = failed; } @Override @@ -61,8 +62,8 @@ } } catch (Throwable th) { - failure=th.toString(); - fail(failure); + failed.set(true); + throw new RuntimeException(th); } } @@ -124,16 +125,15 @@ void doTest(int iter, int nThreads) throws Exception { Thr[] tarr = new Thr[nThreads]; + AtomicBoolean failed = new AtomicBoolean(); for (int i=0; i= file.numBuffers()) { // end of file reached, no more buffers left if (enforceEOF) @@ -95,7 +96,6 @@ } else { currentBuffer = file.getBuffer(currentBufferIndex); bufferPosition = 0; - bufferStart = (long) BUFFER_SIZE * (long) currentBufferIndex; long buflen = length - bufferStart; bufferLength = buflen > BUFFER_SIZE ? BUFFER_SIZE : (int) buflen; }