You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@lucene.apache.org by cp...@apache.org on 2016/10/24 18:32:33 UTC
[29/50] [abbrv] lucene-solr:jira/solr-8542-v2: LUCENE-7515:
RunListenerPrintReproduceInfo may try to access static rule fields without
the rule being called. This flag is needed to ensure this isn't the case.
LUCENE-7515: RunListenerPrintReproduceInfo may try to access static rule fields without
the rule being called. This flag is needed to ensure this isn't the case.
Project: http://git-wip-us.apache.org/repos/asf/lucene-solr/repo
Commit: http://git-wip-us.apache.org/repos/asf/lucene-solr/commit/bc0116af
Tree: http://git-wip-us.apache.org/repos/asf/lucene-solr/tree/bc0116af
Diff: http://git-wip-us.apache.org/repos/asf/lucene-solr/diff/bc0116af
Branch: refs/heads/jira/solr-8542-v2
Commit: bc0116af6928ef921c03b6533c29f230a0fa193e
Parents: a19ec19
Author: Dawid Weiss <dw...@apache.org>
Authored: Fri Oct 21 10:41:38 2016 +0200
Committer: Dawid Weiss <dw...@apache.org>
Committed: Fri Oct 21 11:19:12 2016 +0200
----------------------------------------------------------------------
.../lucene/util/RunListenerPrintReproduceInfo.java | 4 ++--
.../lucene/util/TestRuleSetupAndRestoreClassEnv.java | 13 +++++++++++--
2 files changed, 13 insertions(+), 4 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/lucene-solr/blob/bc0116af/lucene/test-framework/src/java/org/apache/lucene/util/RunListenerPrintReproduceInfo.java
----------------------------------------------------------------------
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 3d4f4fd..7e4c786 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());
http://git-wip-us.apache.org/repos/asf/lucene-solr/blob/bc0116af/lucene/test-framework/src/java/org/apache/lucene/util/TestRuleSetupAndRestoreClassEnv.java
----------------------------------------------------------------------
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 279305e..0e4facc 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
@@ -73,12 +73,16 @@ final class TestRuleSetupAndRestoreClassEnv extends AbstractBeforeAfterRule {
Codec codec;
/**
+ * Indicates whether the rule has executed its {@link #before()} method fully.
+ */
+ private boolean initialized;
+
+ /**
* @see SuppressCodecs
*/
HashSet<String> 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;
}
/**