Apache Lucene open-source search software
null check on infoStream (#637)
Mike Drob56f49257ed64
diff --git a/lucene/core/src/java/org/apache/lucene/index/CheckIndex.java b/lucene/core/src/java/org/apache/lucene/index/CheckIndex.javaindex 3dd5526a877..57080ee4410 100644--- a/lucene/core/src/java/org/apache/lucene/index/CheckIndex.java+++ b/lucene/core/src/java/org/apache/lucene/index/CheckIndex.java@@ -506,6 +506,12 @@ public final class CheckIndex implements Closeable {setInfoStream(out, false);}+ private static void msg(PrintStream out, ByteArrayOutputStream msg) {+ if (out != null) {+ out.println(msg.toString(StandardCharsets.UTF_8));+ }+ }+private static void msg(PrintStream out, String msg) {if (out != null) {out.println(msg);@@ -778,21 +784,21 @@ public final class CheckIndex implements Closeable {} catch (InterruptedException e) {// the segment test output should come before interrupted exception message that follows,// hence it's not emitted from finally clause- infoStream.println(output.toString(StandardCharsets.UTF_8));+ msg(infoStream, output);msg(infoStream,"ERROR: Interrupted exception occurred when getting segment check result for segment "+ info.info.name);if (infoStream != null) e.printStackTrace(infoStream);} catch (ExecutionException e) {- infoStream.println(output.toString(StandardCharsets.UTF_8));+ msg(infoStream, output.toString(StandardCharsets.UTF_8));assert failFast;throw new CheckIndexException("Segment " + info.info.name + " check failed.", e.getCause());}- infoStream.print(output.toString(StandardCharsets.UTF_8));+ msg(infoStream, output);processSegmentInfoStatusResult(result, info, segmentInfoStatus);}