You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@lucene.apache.org by mi...@apache.org on 2015/07/14 14:58:27 UTC
svn commit: r1690919 - in /lucene/dev/branches/branch_5x: ./ lucene/
lucene/core/
lucene/core/src/test/org/apache/lucene/index/TestIndexWriterExceptions.java
Author: mikemccand
Date: Tue Jul 14 12:58:27 2015
New Revision: 1690919
URL: http://svn.apache.org/r1690919
Log:
LUCENE-6579: fix this test case to cope with tragedy
Modified:
lucene/dev/branches/branch_5x/ (props changed)
lucene/dev/branches/branch_5x/lucene/ (props changed)
lucene/dev/branches/branch_5x/lucene/core/ (props changed)
lucene/dev/branches/branch_5x/lucene/core/src/test/org/apache/lucene/index/TestIndexWriterExceptions.java
Modified: lucene/dev/branches/branch_5x/lucene/core/src/test/org/apache/lucene/index/TestIndexWriterExceptions.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/branch_5x/lucene/core/src/test/org/apache/lucene/index/TestIndexWriterExceptions.java?rev=1690919&r1=1690918&r2=1690919&view=diff
==============================================================================
--- lucene/dev/branches/branch_5x/lucene/core/src/test/org/apache/lucene/index/TestIndexWriterExceptions.java (original)
+++ lucene/dev/branches/branch_5x/lucene/core/src/test/org/apache/lucene/index/TestIndexWriterExceptions.java Tue Jul 14 12:58:27 2015
@@ -1884,7 +1884,7 @@ public class TestIndexWriterExceptions e
// full), and then the exception stops (e.g., disk frees
// up), so we successfully close IW or open an NRT
// reader, we don't lose any deletes or updates:
- public void testNoLostDeletesOrUpdates() throws Exception {
+ public void testNoLostDeletesOrUpdates() throws Throwable {
int deleteCount = 0;
int docBase = 0;
int docCount = 0;
@@ -1935,6 +1935,8 @@ public class TestIndexWriterExceptions e
RandomIndexWriter w = null;
+ boolean tragic = false;
+
for(int iter=0;iter<10*RANDOM_MULTIPLIER;iter++) {
int numDocs = atLeast(100);
if (VERBOSE) {
@@ -2038,17 +2040,22 @@ public class TestIndexWriterExceptions e
w = null;
}
- } catch (IOException ioe) {
+ } catch (Throwable t) {
// FakeIOException can be thrown from mergeMiddle, in which case IW
// registers it before our CMS gets to suppress it. IW.forceMerge later
// throws it as a wrapped IOE, so don't fail in this case.
- if (ioe instanceof FakeIOException || (ioe.getCause() != null && ioe.getCause() instanceof FakeIOException)) {
+ if (t instanceof FakeIOException || (t.getCause() instanceof FakeIOException)) {
// expected
if (VERBOSE) {
- System.out.println("TEST: w.close() hit expected IOE");
+ System.out.println("TEST: hit expected IOE");
+ }
+ if (t instanceof AlreadyClosedException) {
+ // FakeIOExc struck during merge and writer is now closed:
+ w = null;
+ tragic = true;
}
} else {
- throw ioe;
+ throw t;
}
}
shouldFail.set(false);
@@ -2079,7 +2086,9 @@ public class TestIndexWriterExceptions e
}
r = w.getReader();
}
- assertEquals(docCount-deleteCount, r.numDocs());
+ if (tragic == false) {
+ assertEquals(docCount-deleteCount, r.numDocs());
+ }
BytesRef scratch = new BytesRef();
for (LeafReaderContext context : r.leaves()) {
LeafReader reader = context.reader();
@@ -2115,9 +2124,11 @@ public class TestIndexWriterExceptions e
}
// Final verify:
- IndexReader r = DirectoryReader.open(dir);
- assertEquals(docCount-deleteCount, r.numDocs());
- r.close();
+ if (tragic == false) {
+ IndexReader r = DirectoryReader.open(dir);
+ assertEquals(docCount-deleteCount, r.numDocs());
+ r.close();
+ }
dir.close();
}