fix possible false failure in testCloseWithThreads case

git-svn-id: https://svn.apache.org/repos/asf/lucene/java/trunk@639961 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
Michael McCandless 2008-03-22 08:23:41 +00:00
parent 10230efa5d
commit df7cf49580
1 changed files with 15 additions and 4 deletions

View File

@ -2257,6 +2257,7 @@ public class TestIndexWriter extends LuceneTestCase
AlreadyClosedException ace;
IndexWriter writer;
boolean noErrors;
volatile int addCount;
public IndexerThread(IndexWriter writer, boolean noErrors) {
this.writer = writer;
@ -2275,6 +2276,7 @@ public class TestIndexWriter extends LuceneTestCase
while(System.currentTimeMillis() < stopTime) {
try {
writer.updateDocument(new Term("id", ""+(idUpto++)), doc);
addCount++;
} catch (IOException ioe) {
//ioe.printStackTrace(System.out);
if (ioe.getMessage().startsWith("fake disk full at") ||
@ -2332,11 +2334,20 @@ public class TestIndexWriter extends LuceneTestCase
for(int i=0;i<NUM_THREADS;i++)
threads[i].start();
boolean done = false;
while(!done) {
try {
Thread.sleep(100);
} catch (InterruptedException ie) {
Thread.currentThread().interrupt();
}
for(int i=0;i<NUM_THREADS;i++)
// only stop when at least one thread has added a doc
if (threads[i].addCount > 0) {
done = true;
break;
}
}
writer.close(false);