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 2022/11/22 14:09:20 UTC

[lucene] 01/04: #10878: revert #02528c6757d10420cc7d545282b49c4322943ac7 (add some test verbosity on failure (#11935))

This is an automated email from the ASF dual-hosted git repository.

mikemccand pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/lucene.git

commit 521c0e24f2d3f7137b2cab8dc99e9f5dace04a9d
Author: Mike McCandless <mi...@apache.org>
AuthorDate: Tue Nov 22 07:59:08 2022 -0500

    #10878: revert #02528c6757d10420cc7d545282b49c4322943ac7 (add some test verbosity on failure (#11935))
---
 .../apache/lucene/index/TestIndexFileDeleter.java  | 33 ++++------------------
 1 file changed, 5 insertions(+), 28 deletions(-)

diff --git a/lucene/core/src/test/org/apache/lucene/index/TestIndexFileDeleter.java b/lucene/core/src/test/org/apache/lucene/index/TestIndexFileDeleter.java
index c10fc32c5c9..01cdbbe0c17 100644
--- a/lucene/core/src/test/org/apache/lucene/index/TestIndexFileDeleter.java
+++ b/lucene/core/src/test/org/apache/lucene/index/TestIndexFileDeleter.java
@@ -16,17 +16,9 @@
  */
 package org.apache.lucene.index;
 
-import java.io.ByteArrayOutputStream;
-import java.io.IOException;
-import java.io.PrintStream;
+import java.io.*;
 import java.nio.file.Path;
-import java.util.ArrayList;
-import java.util.Arrays;
-import java.util.Collection;
-import java.util.HashSet;
-import java.util.Iterator;
-import java.util.List;
-import java.util.Set;
+import java.util.*;
 import java.util.concurrent.atomic.AtomicBoolean;
 import org.apache.lucene.codecs.simpletext.SimpleTextCodec;
 import org.apache.lucene.document.Document;
@@ -42,7 +34,6 @@ import org.apache.lucene.tests.index.RandomIndexWriter;
 import org.apache.lucene.tests.store.MockDirectoryWrapper;
 import org.apache.lucene.tests.util.LuceneTestCase;
 import org.apache.lucene.tests.util.TestUtil;
-import org.apache.lucene.util.IOUtils;
 import org.apache.lucene.util.InfoStream;
 
 /*
@@ -439,19 +430,13 @@ public class TestIndexFileDeleter extends LuceneTestCase {
 
     final AtomicBoolean doFailExc = new AtomicBoolean();
 
-    final ByteArrayOutputStream bytesLog = new ByteArrayOutputStream();
-    final PrintStream log = new PrintStream(bytesLog, true, IOUtils.UTF_8);
-
     dir.failOn(
         new MockDirectoryWrapper.Failure() {
           @Override
           public void eval(MockDirectoryWrapper dir) throws IOException {
             if (doFailExc.get() && random().nextInt(4) == 1) {
               if (callStackContains(IndexFileDeleter.class, "decRef")) {
-                RuntimeException re = new RuntimeException("fake fail");
-                log.println("Now throw fake exception:");
-                re.printStackTrace(log);
-                throw re;
+                throw new RuntimeException("fake fail");
               }
             }
           }
@@ -468,15 +453,11 @@ public class TestIndexFileDeleter extends LuceneTestCase {
               // suppress only FakeIOException:
               if (exc instanceof RuntimeException && exc.getMessage().equals("fake fail")) {
                 // ok to ignore
-                log.println("Ignoring \"ok\" exception:");
-                exc.printStackTrace(log);
               } else if ((exc instanceof AlreadyClosedException
                       || exc instanceof IllegalStateException)
                   && exc.getCause() != null
                   && "fake fail".equals(exc.getCause().getMessage())) {
                 // also ok to ignore
-                log.println("Ignoring \"ok\" exception:");
-                exc.printStackTrace(log);
               } else {
                 super.handleMergeException(exc);
               }
@@ -508,14 +489,10 @@ public class TestIndexFileDeleter extends LuceneTestCase {
           w.addDocument(doc);
         }
       } catch (Throwable t) {
-        if ((t.toString().contains("fake fail")
-            || (t.getCause() != null && t.getCause().toString().contains("fake fail")))) {
+        if (t.toString().contains("fake fail")
+            || (t.getCause() != null && t.getCause().toString().contains("fake fail"))) {
           // ok
-          log.println("Ignoring \"ok\" exception:");
-          t.printStackTrace(log);
         } else {
-          System.out.println("test failed!  full log:");
-          System.out.print(bytesLog.toString("UTF-8"));
           throw t;
         }
       }