Apache Lucene open-source search software
LUCENE-7690: also handle expected CorruptIndexException in this test
Mike McCandlessf1c5cd5784dd
diff --git a/lucene/test-framework/src/java/org/apache/lucene/index/BasePointsFormatTestCase.java b/lucene/test-framework/src/java/org/apache/lucene/index/BasePointsFormatTestCase.javaindex 4cd6534d64e..ca68d2e3610 100644--- a/lucene/test-framework/src/java/org/apache/lucene/index/BasePointsFormatTestCase.java+++ b/lucene/test-framework/src/java/org/apache/lucene/index/BasePointsFormatTestCase.java@@ -40,6 +40,7 @@ import org.apache.lucene.util.Bits;import org.apache.lucene.util.BytesRef;import org.apache.lucene.util.IOUtils;import org.apache.lucene.util.NumericUtils;+import org.apache.lucene.util.Rethrow;import org.apache.lucene.util.StringHelper;import org.apache.lucene.util.TestUtil;@@ -232,16 +233,7 @@ public abstract class BasePointsFormatTestCase extends BaseIndexFileFormatTestCadir.setRandomIOExceptionRateOnOpen(0.05);verify(dir, docValues, null, numDims, numBytesPerDim, true);} catch (IllegalStateException ise) {- if (ise.getMessage().contains("this writer hit an unrecoverable error")) {- Throwable cause = ise.getCause();- if (cause != null && cause.getMessage().contains("a random IOException")) {- done = true;- } else {- throw ise;- }- } else {- throw ise;- }+ done = handlePossiblyFakeException(ise);} catch (AssertionError ae) {if (ae.getMessage() != null && ae.getMessage().contains("does not exist; files=")) {// OK: likely we threw the random IOExc when IW was asserting the commit files exist@@ -253,23 +245,28 @@ public abstract class BasePointsFormatTestCase extends BaseIndexFileFormatTestCa// This just means we got a too-small maxMB for the maxPointsInLeafNode; just retry w/ more heapassertTrue(iae.getMessage().contains("either increase maxMBSortInHeap or decrease maxPointsInLeafNode"));} catch (IOException ioe) {- Throwable ex = ioe;- while (ex != null) {- String message = ex.getMessage();- if (message != null && (message.contains("a random IOException") || message.contains("background merge hit exception"))) {- done = true;- break;- }- ex = ex.getCause();- }- if (done == false) {- throw ioe;- }+ done = handlePossiblyFakeException(ioe);}}}}+ // TODO: merge w/ BaseIndexFileFormatTestCase.handleFakeIOException+ private boolean handlePossiblyFakeException(Exception e) {+ Throwable ex = e;+ while (ex != null) {+ String message = ex.getMessage();+ if (message != null && (message.contains("a random IOException") || message.contains("background merge hit exception"))) {+ return true;+ }+ ex = ex.getCause();+ }+ Rethrow.rethrow(e);++ // dead code yet javac disagrees:+ return false;+ }+public void testMultiValued() throws Exception {int numBytesPerDim = TestUtil.nextInt(random(), 2, PointValues.MAX_NUM_BYTES);int numDims = TestUtil.nextInt(random(), 1, PointValues.MAX_DIMENSIONS);