mirror of https://github.com/apache/lucene.git
LUCENE-6802: fix test bug: if CMS hits tragic exception, writer is already closed
git-svn-id: https://svn.apache.org/repos/asf/lucene/dev/trunk@1702796 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
parent
b57234a745
commit
0c3b522d28
|
@ -1931,22 +1931,6 @@ public class TestIndexWriterExceptions extends LuceneTestCase {
|
||||||
}
|
}
|
||||||
if (w == null) {
|
if (w == null) {
|
||||||
IndexWriterConfig iwc = newIndexWriterConfig(new MockAnalyzer(random()));
|
IndexWriterConfig iwc = newIndexWriterConfig(new MockAnalyzer(random()));
|
||||||
final MergeScheduler ms = iwc.getMergeScheduler();
|
|
||||||
if (ms instanceof ConcurrentMergeScheduler) {
|
|
||||||
final ConcurrentMergeScheduler suppressFakeIOE = new ConcurrentMergeScheduler() {
|
|
||||||
@Override
|
|
||||||
protected void handleMergeException(Directory dir, Throwable exc) {
|
|
||||||
// suppress only FakeIOException:
|
|
||||||
if (!(exc instanceof FakeIOException)) {
|
|
||||||
super.handleMergeException(dir, exc);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
};
|
|
||||||
final ConcurrentMergeScheduler cms = (ConcurrentMergeScheduler) ms;
|
|
||||||
suppressFakeIOE.setMaxMergesAndThreads(cms.getMaxMergeCount(), cms.getMaxThreadCount());
|
|
||||||
iwc.setMergeScheduler(suppressFakeIOE);
|
|
||||||
}
|
|
||||||
|
|
||||||
w = new RandomIndexWriter(random(), dir, iwc);
|
w = new RandomIndexWriter(random(), dir, iwc);
|
||||||
// Since we hit exc during merging, a partial
|
// Since we hit exc during merging, a partial
|
||||||
// forceMerge can easily return when there are still
|
// forceMerge can easily return when there are still
|
||||||
|
@ -2047,6 +2031,18 @@ public class TestIndexWriterExceptions extends LuceneTestCase {
|
||||||
}
|
}
|
||||||
shouldFail.set(false);
|
shouldFail.set(false);
|
||||||
|
|
||||||
|
if (w != null) {
|
||||||
|
MergeScheduler ms = w.w.getConfig().getMergeScheduler();
|
||||||
|
if (ms instanceof ConcurrentMergeScheduler) {
|
||||||
|
((ConcurrentMergeScheduler) ms).sync();
|
||||||
|
}
|
||||||
|
|
||||||
|
if (w.w.getTragicException() != null) {
|
||||||
|
// Tragic exc in CMS closed the writer
|
||||||
|
w = null;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
IndexReader r;
|
IndexReader r;
|
||||||
|
|
||||||
if (doClose && w != null) {
|
if (doClose && w != null) {
|
||||||
|
|
Loading…
Reference in New Issue