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:
Michael McCandless 2015-09-13 17:39:37 +00:00
parent b57234a745
commit 0c3b522d28
1 changed files with 12 additions and 16 deletions

View File

@ -1931,22 +1931,6 @@ public class TestIndexWriterExceptions extends LuceneTestCase {
}
if (w == null) {
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);
// Since we hit exc during merging, a partial
// forceMerge can easily return when there are still
@ -2047,6 +2031,18 @@ public class TestIndexWriterExceptions extends LuceneTestCase {
}
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;
if (doClose && w != null) {