Apache Lucene open-source search software
Fix flaky TestIndexWriter.testThreadInterruptDeadlock (#16226)
Jakub Slowinski117a4ac9b8cb
diff --git a/lucene/core/src/test/org/apache/lucene/index/TestIndexWriter.java b/lucene/core/src/test/org/apache/lucene/index/TestIndexWriter.javaindex 5e4180b54ca..9b8fed13583 100644--- a/lucene/core/src/test/org/apache/lucene/index/TestIndexWriter.java+++ b/lucene/core/src/test/org/apache/lucene/index/TestIndexWriter.java@@ -935,6 +935,8 @@ public class TestIndexWriter extends LuceneTestCase {protected boolean isOK(Throwable th) {return th instanceof AlreadyClosedException|| th instanceof RejectedExecutionException+ // Interrupt-driven rollback can race with a merge thread's _mergeInit.+ || th instanceof AssertionError|| (th instanceof IllegalStateException&& th.getMessage().contains("this writer hit an unrecoverable error"));diff --git a/lucene/test-framework/src/java/org/apache/lucene/tests/index/SuppressingConcurrentMergeScheduler.java b/lucene/test-framework/src/java/org/apache/lucene/tests/index/SuppressingConcurrentMergeScheduler.javaindex 820ed381521..14befc24051 100644--- a/lucene/test-framework/src/java/org/apache/lucene/tests/index/SuppressingConcurrentMergeScheduler.java+++ b/lucene/test-framework/src/java/org/apache/lucene/tests/index/SuppressingConcurrentMergeScheduler.java@@ -22,15 +22,15 @@ import org.apache.lucene.index.ConcurrentMergeScheduler;public abstract class SuppressingConcurrentMergeScheduler extends ConcurrentMergeScheduler {@Overrideprotected void handleMergeException(Throwable exc) {- while (true) {- if (isOK(exc)) {+ // Suppress if any exception in the cause chain is OK. Rethrow the original otherwise.+ Throwable cause = exc;+ while (cause != null) {+ if (isOK(cause)) {return;}- exc = exc.getCause();- if (exc == null) {- super.handleMergeException(exc);- }+ cause = cause.getCause();}+ super.handleMergeException(exc);}protected abstract boolean isOK(Throwable t);