You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@lucene.apache.org by ho...@apache.org on 2019/12/18 23:49:34 UTC
[lucene-solr] branch branch_8x updated: SOLR-14099: expanded
comment on static final variable based on followup questions in Jira from
Dawid
This is an automated email from the ASF dual-hosted git repository.
hossman pushed a commit to branch branch_8x
in repository https://gitbox.apache.org/repos/asf/lucene-solr.git
The following commit(s) were added to refs/heads/branch_8x by this push:
new f071451 SOLR-14099: expanded comment on static final variable based on followup questions in Jira from Dawid
f071451 is described below
commit f0714517e4384f5256f8d75185e1539bd0c177e9
Author: Chris Hostetter <ho...@apache.org>
AuthorDate: Wed Dec 18 16:36:27 2019 -0700
SOLR-14099: expanded comment on static final variable based on followup questions in Jira from Dawid
(cherry picked from commit d30f90e34963f63c07df53df82960f927ab20a8e)
---
.../org/apache/solr/TestLogLevelAnnotations.java | 22 ++++++++++++++++++++--
1 file changed, 20 insertions(+), 2 deletions(-)
diff --git a/solr/test-framework/src/test/org/apache/solr/TestLogLevelAnnotations.java b/solr/test-framework/src/test/org/apache/solr/TestLogLevelAnnotations.java
index 22c0bb6..bc5b943 100644
--- a/solr/test-framework/src/test/org/apache/solr/TestLogLevelAnnotations.java
+++ b/solr/test-framework/src/test/org/apache/solr/TestLogLevelAnnotations.java
@@ -34,7 +34,24 @@ public class TestLogLevelAnnotations extends SolrTestCaseJ4 {
private static final String bogus_logger_prefix = "org.apache.solr.bogus_logger";
/**
- * We don't want a hardocded assumption here because it may change based on how the user runs the test.
+ * <p>
+ * The default log level of the root logger when this class is loaded by the JVM, Used to validate
+ * some logger configurations when the tests are run.
+ * </p>
+ * <p>
+ * We don't want a hardcoded assumption here because it may change based on how the user runs the test.
+ * </p>
+ * <p>
+ * We also don't want to initialize this in a <code>@BeforeClass</code> method because that will run
+ * <em>after</em> the <code>@BeforeClass</code> logic of our super class {@link SolrTestCaseJ4}
+ * where the <code>@LogLevel</code> annotation on this class will be parsed and evaluated -- modifying the
+ * log4j run time configuration.
+ * There is no reason why the <code>@LogLevel</code> configuration of this class <em>should</em> affect
+ * the "root" Logger, but setting this in static class initialization protect us (as best we can)
+ * against the possibility that it <em>might</em> due to an unforseen (future) bug.
+ * </p>
+ *
+ * @see #checkLogLevelsBeforeClass
*/
public static final Level DEFAULT_LOG_LEVEL = LogManager.getRootLogger().getLevel();
@@ -49,7 +66,8 @@ public class TestLogLevelAnnotations extends SolrTestCaseJ4 {
final Configuration config = ctx.getConfiguration();
// NOTE: we're checking the CONFIGURATION of the loggers, not the "effective" value of the Logger
- assertEquals(DEFAULT_LOG_LEVEL, config.getRootLogger().getLevel());
+ assertEquals("Somehow, the configured value of the root logger changed since this class was loaded",
+ DEFAULT_LOG_LEVEL, config.getRootLogger().getLevel());
assertEquals("Your Logger conf sets a level on a bogus package that breaks this test: "
+ bogus_logger_prefix,
config.getRootLogger(),