You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@lucene.apache.org by ab...@apache.org on 2017/02/15 19:00:26 UTC
[22/52] [abbrv] lucene-solr:jira/solr-9858: LUCENE-7690: also handle
expected CorruptIndexException in this test
LUCENE-7690: also handle expected CorruptIndexException in this test
Project: http://git-wip-us.apache.org/repos/asf/lucene-solr/repo
Commit: http://git-wip-us.apache.org/repos/asf/lucene-solr/commit/f1c5cd57
Tree: http://git-wip-us.apache.org/repos/asf/lucene-solr/tree/f1c5cd57
Diff: http://git-wip-us.apache.org/repos/asf/lucene-solr/diff/f1c5cd57
Branch: refs/heads/jira/solr-9858
Commit: f1c5cd5784dd50a030c2923d2ad25d5178f60e6a
Parents: 563f522
Author: Mike McCandless <mi...@apache.org>
Authored: Mon Feb 13 10:29:38 2017 -0500
Committer: Mike McCandless <mi...@apache.org>
Committed: Mon Feb 13 10:29:56 2017 -0500
----------------------------------------------------------------------
.../lucene/index/BasePointsFormatTestCase.java | 41 +++++++++-----------
1 file changed, 19 insertions(+), 22 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/lucene-solr/blob/f1c5cd57/lucene/test-framework/src/java/org/apache/lucene/index/BasePointsFormatTestCase.java
----------------------------------------------------------------------
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.java
index 4cd6534..ca68d2e 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 BaseIndexFileFormatTestCa
dir.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 heap
assertTrue(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);