lucene-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From mikemcc...@apache.org
Subject svn commit: r1690918 - /lucene/dev/trunk/lucene/core/src/test/org/apache/lucene/index/TestIndexWriterExceptions.java
Date Tue, 14 Jul 2015 12:57:51 GMT
Author: mikemccand
Date: Tue Jul 14 12:57:51 2015
New Revision: 1690918

URL: http://svn.apache.org/r1690918
Log:
LUCENE-6579: fix this test case to cope with tragedy

Modified:
    lucene/dev/trunk/lucene/core/src/test/org/apache/lucene/index/TestIndexWriterExceptions.java

Modified: lucene/dev/trunk/lucene/core/src/test/org/apache/lucene/index/TestIndexWriterExceptions.java
URL: http://svn.apache.org/viewvc/lucene/dev/trunk/lucene/core/src/test/org/apache/lucene/index/TestIndexWriterExceptions.java?rev=1690918&r1=1690917&r2=1690918&view=diff
==============================================================================
--- lucene/dev/trunk/lucene/core/src/test/org/apache/lucene/index/TestIndexWriterExceptions.java
(original)
+++ lucene/dev/trunk/lucene/core/src/test/org/apache/lucene/index/TestIndexWriterExceptions.java
Tue Jul 14 12:57:51 2015
@@ -1871,7 +1871,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;
@@ -1922,6 +1922,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) {
@@ -2025,17 +2027,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);
@@ -2066,7 +2073,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();
@@ -2102,9 +2111,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();
   }



Mime
View raw message