mirror of https://github.com/apache/lucene.git
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:
parent
10230efa5d
commit
df7cf49580
|
@ -2257,6 +2257,7 @@ public class TestIndexWriter extends LuceneTestCase
|
||||||
AlreadyClosedException ace;
|
AlreadyClosedException ace;
|
||||||
IndexWriter writer;
|
IndexWriter writer;
|
||||||
boolean noErrors;
|
boolean noErrors;
|
||||||
|
volatile int addCount;
|
||||||
|
|
||||||
public IndexerThread(IndexWriter writer, boolean noErrors) {
|
public IndexerThread(IndexWriter writer, boolean noErrors) {
|
||||||
this.writer = writer;
|
this.writer = writer;
|
||||||
|
@ -2275,6 +2276,7 @@ public class TestIndexWriter extends LuceneTestCase
|
||||||
while(System.currentTimeMillis() < stopTime) {
|
while(System.currentTimeMillis() < stopTime) {
|
||||||
try {
|
try {
|
||||||
writer.updateDocument(new Term("id", ""+(idUpto++)), doc);
|
writer.updateDocument(new Term("id", ""+(idUpto++)), doc);
|
||||||
|
addCount++;
|
||||||
} catch (IOException ioe) {
|
} catch (IOException ioe) {
|
||||||
//ioe.printStackTrace(System.out);
|
//ioe.printStackTrace(System.out);
|
||||||
if (ioe.getMessage().startsWith("fake disk full at") ||
|
if (ioe.getMessage().startsWith("fake disk full at") ||
|
||||||
|
@ -2332,10 +2334,19 @@ public class TestIndexWriter extends LuceneTestCase
|
||||||
for(int i=0;i<NUM_THREADS;i++)
|
for(int i=0;i<NUM_THREADS;i++)
|
||||||
threads[i].start();
|
threads[i].start();
|
||||||
|
|
||||||
try {
|
boolean done = false;
|
||||||
Thread.sleep(100);
|
while(!done) {
|
||||||
} catch (InterruptedException ie) {
|
try {
|
||||||
Thread.currentThread().interrupt();
|
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);
|
writer.close(false);
|
||||||
|
|
Loading…
Reference in New Issue