diff --git a/lucene/test-framework/src/java/org/apache/lucene/util/RunListenerPrintReproduceInfo.java b/lucene/test-framework/src/java/org/apache/lucene/util/RunListenerPrintReproduceInfo.java index 3d4f4fd9819..7e4c7867ffa 100644 --- a/lucene/test-framework/src/java/org/apache/lucene/util/RunListenerPrintReproduceInfo.java +++ b/lucene/test-framework/src/java/org/apache/lucene/util/RunListenerPrintReproduceInfo.java @@ -125,7 +125,7 @@ public final class RunListenerPrintReproduceInfo extends RunListener { /** print some useful debugging information about the environment */ private static void printDebuggingInformation() { - if (classEnvRule != null) { + if (classEnvRule != null && classEnvRule.isInitialized()) { System.err.println("NOTE: test params are: codec=" + classEnvRule.codec + ", sim=" + classEnvRule.similarity + ", locale=" + classEnvRule.locale.toLanguageTag() + @@ -176,7 +176,7 @@ public final class RunListenerPrintReproduceInfo extends RunListener { // Environment. if (!TEST_LINE_DOCS_FILE.equals(DEFAULT_LINE_DOCS_FILE)) addVmOpt(b, "tests.linedocsfile", TEST_LINE_DOCS_FILE); - if (classEnvRule != null) { + if (classEnvRule != null && classEnvRule.isInitialized()) { addVmOpt(b, "tests.locale", classEnvRule.locale.toLanguageTag()); if (classEnvRule.timeZone != null) { addVmOpt(b, "tests.timezone", classEnvRule.timeZone.getID()); diff --git a/lucene/test-framework/src/java/org/apache/lucene/util/TestRuleSetupAndRestoreClassEnv.java b/lucene/test-framework/src/java/org/apache/lucene/util/TestRuleSetupAndRestoreClassEnv.java index 279305e7cfb..0e4facc5249 100644 --- a/lucene/test-framework/src/java/org/apache/lucene/util/TestRuleSetupAndRestoreClassEnv.java +++ b/lucene/test-framework/src/java/org/apache/lucene/util/TestRuleSetupAndRestoreClassEnv.java @@ -72,13 +72,17 @@ final class TestRuleSetupAndRestoreClassEnv extends AbstractBeforeAfterRule { Similarity similarity; Codec codec; + /** + * Indicates whether the rule has executed its {@link #before()} method fully. + */ + private boolean initialized; + /** * @see SuppressCodecs */ HashSet avoidCodecs; static class ThreadNameFixingPrintStreamInfoStream extends PrintStreamInfoStream { - public ThreadNameFixingPrintStreamInfoStream(PrintStream out) { super(out); } @@ -99,6 +103,10 @@ final class TestRuleSetupAndRestoreClassEnv extends AbstractBeforeAfterRule { stream.println(component + " " + messageID + " [" + getTimestamp() + "; " + name + "]: " + message); } } + + public boolean isInitialized() { + return initialized; + } @Override protected void before() throws Exception { @@ -113,7 +121,6 @@ final class TestRuleSetupAndRestoreClassEnv extends AbstractBeforeAfterRule { if (VERBOSE) { System.out.println("Loaded codecs: " + Codec.availableCodecs()); System.out.println("Loaded postingsFormats: " + PostingsFormat.availablePostingsFormats()); - } savedInfoStream = InfoStream.getDefault(); @@ -235,6 +242,8 @@ final class TestRuleSetupAndRestoreClassEnv extends AbstractBeforeAfterRule { } LuceneTestCase.setLiveIWCFlushMode(flushMode); + + initialized = true; } /**