You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@lucene.apache.org by dw...@apache.org on 2016/10/21 09:19:45 UTC

[1/2] lucene-solr:master: 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.

Repository: lucene-solr
Updated Branches:
  refs/heads/branch_6x a08a2a296 -> f379dde2d
  refs/heads/master a19ec194d -> bc0116af6


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/master
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;
   }
 
   /**


[2/2] lucene-solr:branch_6x: 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.

Posted by dw...@apache.org.
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/f379dde2
Tree: http://git-wip-us.apache.org/repos/asf/lucene-solr/tree/f379dde2
Diff: http://git-wip-us.apache.org/repos/asf/lucene-solr/diff/f379dde2

Branch: refs/heads/branch_6x
Commit: f379dde2d7206bd406b43a4ed7d0f8671b2f2e7b
Parents: a08a2a2
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:37 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/f379dde2/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/f379dde2/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 5c88dc7..d71510e 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;
   }
 
   /**