mirror of https://github.com/apache/lucene.git
fix test to hard close
git-svn-id: https://svn.apache.org/repos/asf/lucene/dev/trunk@1586134 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
parent
d1b922fe12
commit
f261d484f4
|
@ -18,6 +18,7 @@ package org.apache.lucene.index;
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.Random;
|
import java.util.Random;
|
||||||
|
import java.util.concurrent.atomic.AtomicReference;
|
||||||
|
|
||||||
import org.apache.lucene.analysis.MockAnalyzer;
|
import org.apache.lucene.analysis.MockAnalyzer;
|
||||||
import org.apache.lucene.document.Document;
|
import org.apache.lucene.document.Document;
|
||||||
|
@ -131,7 +132,7 @@ public class TestIndexWriterMerging extends LuceneTestCase
|
||||||
FieldType customType = new FieldType();
|
FieldType customType = new FieldType();
|
||||||
customType.setStored(true);
|
customType.setStored(true);
|
||||||
|
|
||||||
FieldType customType1 = new FieldType(TextField.TYPE_NOT_STORED);
|
FieldType customType1 = new FieldType(TextField.TYPE_STORED);
|
||||||
customType1.setTokenized(false);
|
customType1.setTokenized(false);
|
||||||
customType1.setStoreTermVectors(true);
|
customType1.setStoreTermVectors(true);
|
||||||
customType1.setStoreTermVectorPositions(true);
|
customType1.setStoreTermVectorPositions(true);
|
||||||
|
@ -360,7 +361,7 @@ public class TestIndexWriterMerging extends LuceneTestCase
|
||||||
}
|
}
|
||||||
|
|
||||||
final Document doc = new Document();
|
final Document doc = new Document();
|
||||||
FieldType customType = new FieldType(TextField.TYPE_STORED);
|
FieldType customType = new FieldType(TextField.TYPE_NOT_STORED);
|
||||||
customType.setTokenized(false);
|
customType.setTokenized(false);
|
||||||
|
|
||||||
Field idField = newField("id", "", customType);
|
Field idField = newField("id", "", customType);
|
||||||
|
@ -398,12 +399,14 @@ public class TestIndexWriterMerging extends LuceneTestCase
|
||||||
delID += 5;
|
delID += 5;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
writer.commit();
|
||||||
|
|
||||||
// Force a bunch of merge threads to kick off so we
|
// Force a bunch of merge threads to kick off so we
|
||||||
// stress out aborting them on close:
|
// stress out aborting them on close:
|
||||||
((LogMergePolicy) writer.getConfig().getMergePolicy()).setMergeFactor(2);
|
((LogMergePolicy) writer.getConfig().getMergePolicy()).setMergeFactor(2);
|
||||||
|
|
||||||
final IndexWriter finalWriter = writer;
|
final IndexWriter finalWriter = writer;
|
||||||
final ArrayList<Throwable> failure = new ArrayList<>();
|
final AtomicReference<Throwable> failure = new AtomicReference<>();
|
||||||
Thread t1 = new Thread() {
|
Thread t1 = new Thread() {
|
||||||
@Override
|
@Override
|
||||||
public void run() {
|
public void run() {
|
||||||
|
@ -420,7 +423,7 @@ public class TestIndexWriterMerging extends LuceneTestCase
|
||||||
break;
|
break;
|
||||||
} catch (Throwable e) {
|
} catch (Throwable e) {
|
||||||
e.printStackTrace(System.out);
|
e.printStackTrace(System.out);
|
||||||
failure.add(e);
|
failure.set(e);
|
||||||
done = true;
|
done = true;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
@ -431,15 +434,15 @@ public class TestIndexWriterMerging extends LuceneTestCase
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
if (failure.size() > 0) {
|
|
||||||
throw failure.get(0);
|
|
||||||
}
|
|
||||||
|
|
||||||
t1.start();
|
t1.start();
|
||||||
|
|
||||||
writer.shutdown(false);
|
writer.close();
|
||||||
t1.join();
|
t1.join();
|
||||||
|
|
||||||
|
if (failure.get() != null) {
|
||||||
|
throw failure.get();
|
||||||
|
}
|
||||||
|
|
||||||
// Make sure reader can read
|
// Make sure reader can read
|
||||||
IndexReader reader = DirectoryReader.open(directory);
|
IndexReader reader = DirectoryReader.open(directory);
|
||||||
reader.close();
|
reader.close();
|
||||||
|
|
Loading…
Reference in New Issue