You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@logging.apache.org by gg...@apache.org on 2018/10/19 17:44:30 UTC
logging-log4j2 git commit: [LOG4J2-2134] StackOverflowError at
AwaitCompletionReliabilityStrategy. Closes #221.
Repository: logging-log4j2
Updated Branches:
refs/heads/release-2.x effd3933f -> 7b3d22b5d
[LOG4J2-2134] StackOverflowError at AwaitCompletionReliabilityStrategy.
Closes #221.
Project: http://git-wip-us.apache.org/repos/asf/logging-log4j2/repo
Commit: http://git-wip-us.apache.org/repos/asf/logging-log4j2/commit/7b3d22b5
Tree: http://git-wip-us.apache.org/repos/asf/logging-log4j2/tree/7b3d22b5
Diff: http://git-wip-us.apache.org/repos/asf/logging-log4j2/diff/7b3d22b5
Branch: refs/heads/release-2.x
Commit: 7b3d22b5df2fa16d393ccabac091f29747fcfdea
Parents: effd393
Author: Gary Gregory <gg...@apache.org>
Authored: Fri Oct 19 11:44:22 2018 -0600
Committer: Gary Gregory <gg...@apache.org>
Committed: Fri Oct 19 11:44:22 2018 -0600
----------------------------------------------------------------------
.../AwaitCompletionReliabilityStrategy.java | 11 +-
.../core/config/LockingReliabilityStrategy.java | 12 +-
.../log4j/core/config/JiraLog4j2_2134Test.java | 117 +++++++++++++++++++
log4j-core/src/test/resources/log4j2-2134.yml | 13 +++
src/changes/changes.xml | 3 +
5 files changed, 145 insertions(+), 11 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/logging-log4j2/blob/7b3d22b5/log4j-core/src/main/java/org/apache/logging/log4j/core/config/AwaitCompletionReliabilityStrategy.java
----------------------------------------------------------------------
diff --git a/log4j-core/src/main/java/org/apache/logging/log4j/core/config/AwaitCompletionReliabilityStrategy.java b/log4j-core/src/main/java/org/apache/logging/log4j/core/config/AwaitCompletionReliabilityStrategy.java
index ccc35d0..b27940d 100644
--- a/log4j-core/src/main/java/org/apache/logging/log4j/core/config/AwaitCompletionReliabilityStrategy.java
+++ b/log4j-core/src/main/java/org/apache/logging/log4j/core/config/AwaitCompletionReliabilityStrategy.java
@@ -49,7 +49,7 @@ public class AwaitCompletionReliabilityStrategy implements ReliabilityStrategy {
/*
* (non-Javadoc)
- *
+ *
* @see org.apache.logging.log4j.core.config.ReliabilityStrategy#log(org.apache.logging.log4j.util.Supplier,
* java.lang.String, java.lang.String, org.apache.logging.log4j.Marker, org.apache.logging.log4j.Level,
* org.apache.logging.log4j.message.Message, java.lang.Throwable)
@@ -68,7 +68,7 @@ public class AwaitCompletionReliabilityStrategy implements ReliabilityStrategy {
/*
* (non-Javadoc)
- *
+ *
* @see org.apache.logging.log4j.core.config.ReliabilityStrategy#log(org.apache.logging.log4j.util.Supplier,
* org.apache.logging.log4j.core.LogEvent)
*/
@@ -84,7 +84,7 @@ public class AwaitCompletionReliabilityStrategy implements ReliabilityStrategy {
/*
* (non-Javadoc)
- *
+ *
* @see
* org.apache.logging.log4j.core.config.ReliabilityStrategy#beforeLogEvent(org.apache.logging.log4j.core.config.
* LoggerConfig, org.apache.logging.log4j.util.Supplier)
@@ -94,6 +94,7 @@ public class AwaitCompletionReliabilityStrategy implements ReliabilityStrategy {
LoggerConfig result = this.loggerConfig;
if (!beforeLogEvent()) {
result = next.get();
+ //return result == this.loggerConfig ? result : result.getReliabilityStrategy().getActiveLoggerConfig(next);
return result.getReliabilityStrategy().getActiveLoggerConfig(next);
}
return result;
@@ -122,7 +123,7 @@ public class AwaitCompletionReliabilityStrategy implements ReliabilityStrategy {
/*
* (non-Javadoc)
- *
+ *
* @see org.apache.logging.log4j.core.config.ReliabilityStrategy#beforeStopAppenders()
*/
@Override
@@ -162,7 +163,7 @@ public class AwaitCompletionReliabilityStrategy implements ReliabilityStrategy {
/*
* (non-Javadoc)
- *
+ *
* @see
* org.apache.logging.log4j.core.config.ReliabilityStrategy#beforeStopConfiguration(org.apache.logging.log4j.core
* .config.Configuration)
http://git-wip-us.apache.org/repos/asf/logging-log4j2/blob/7b3d22b5/log4j-core/src/main/java/org/apache/logging/log4j/core/config/LockingReliabilityStrategy.java
----------------------------------------------------------------------
diff --git a/log4j-core/src/main/java/org/apache/logging/log4j/core/config/LockingReliabilityStrategy.java b/log4j-core/src/main/java/org/apache/logging/log4j/core/config/LockingReliabilityStrategy.java
index c930f8b..35215c1 100644
--- a/log4j-core/src/main/java/org/apache/logging/log4j/core/config/LockingReliabilityStrategy.java
+++ b/log4j-core/src/main/java/org/apache/logging/log4j/core/config/LockingReliabilityStrategy.java
@@ -41,7 +41,7 @@ public class LockingReliabilityStrategy implements ReliabilityStrategy {
/*
* (non-Javadoc)
- *
+ *
* @see org.apache.logging.log4j.core.config.ReliabilityStrategy#log(org.apache.logging.log4j.util.Supplier,
* java.lang.String, java.lang.String, org.apache.logging.log4j.Marker, org.apache.logging.log4j.Level,
* org.apache.logging.log4j.message.Message, java.lang.Throwable)
@@ -60,7 +60,7 @@ public class LockingReliabilityStrategy implements ReliabilityStrategy {
/*
* (non-Javadoc)
- *
+ *
* @see org.apache.logging.log4j.core.config.ReliabilityStrategy#log(org.apache.logging.log4j.util.Supplier,
* org.apache.logging.log4j.core.LogEvent)
*/
@@ -76,7 +76,7 @@ public class LockingReliabilityStrategy implements ReliabilityStrategy {
/*
* (non-Javadoc)
- *
+ *
* @see
* org.apache.logging.log4j.core.config.ReliabilityStrategy#beforeLogEvent(org.apache.logging.log4j.core.config.
* LoggerConfig, org.apache.logging.log4j.util.Supplier)
@@ -86,7 +86,7 @@ public class LockingReliabilityStrategy implements ReliabilityStrategy {
LoggerConfig result = this.loggerConfig;
if (!beforeLogEvent()) {
result = next.get();
- return result.getReliabilityStrategy().getActiveLoggerConfig(next);
+ return result == this.loggerConfig ? result : result.getReliabilityStrategy().getActiveLoggerConfig(next);
}
return result;
}
@@ -107,7 +107,7 @@ public class LockingReliabilityStrategy implements ReliabilityStrategy {
/*
* (non-Javadoc)
- *
+ *
* @see org.apache.logging.log4j.core.config.ReliabilityStrategy#beforeStopAppenders()
*/
@Override
@@ -122,7 +122,7 @@ public class LockingReliabilityStrategy implements ReliabilityStrategy {
/*
* (non-Javadoc)
- *
+ *
* @see
* org.apache.logging.log4j.core.config.ReliabilityStrategy#beforeStopConfiguration(org.apache.logging.log4j.core
* .config.Configuration)
http://git-wip-us.apache.org/repos/asf/logging-log4j2/blob/7b3d22b5/log4j-core/src/test/java/org/apache/logging/log4j/core/config/JiraLog4j2_2134Test.java
----------------------------------------------------------------------
diff --git a/log4j-core/src/test/java/org/apache/logging/log4j/core/config/JiraLog4j2_2134Test.java b/log4j-core/src/test/java/org/apache/logging/log4j/core/config/JiraLog4j2_2134Test.java
new file mode 100644
index 0000000..37508bb
--- /dev/null
+++ b/log4j-core/src/test/java/org/apache/logging/log4j/core/config/JiraLog4j2_2134Test.java
@@ -0,0 +1,117 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache license, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the license for the specific language governing permissions and
+ * limitations under the license.
+ */
+
+package org.apache.logging.log4j.core.config;
+
+import org.apache.logging.log4j.Level;
+import org.apache.logging.log4j.LogManager;
+import org.apache.logging.log4j.Logger;
+import org.apache.logging.log4j.core.Appender;
+import org.apache.logging.log4j.core.LoggerContext;
+import org.apache.logging.log4j.core.appender.FileAppender;
+import org.apache.logging.log4j.core.layout.PatternLayout;
+import org.apache.logging.log4j.junit.LoggerContextRule;
+import org.junit.Rule;
+import org.junit.Test;
+
+public class JiraLog4j2_2134Test {
+
+ @Rule
+ public final LoggerContextRule loggerContextRule = new LoggerContextRule("src/test/resources/log4j2-2134.yml");
+
+ @Test
+ public void testRefresh() {
+ Logger log = LogManager.getLogger(this.getClass());
+ final LoggerContext ctx = (LoggerContext) LogManager.getContext(false);
+ final Configuration config = ctx.getConfiguration();
+ PatternLayout layout = PatternLayout.newBuilder()
+ // @formatter:off
+ .withPattern(PatternLayout.SIMPLE_CONVERSION_PATTERN)
+ .withConfiguration(config)
+ .build();
+ // @formatter:on
+ Appender appender = FileAppender.newBuilder().withFileName("target/test.log").withLayout(layout)
+ .setConfiguration(config).withBufferSize(4000).withName("File").build();
+ // appender.start();
+ config.addAppender(appender);
+ AppenderRef ref = AppenderRef.createAppenderRef("File", null, null);
+ AppenderRef[] refs = new AppenderRef[] { ref };
+ LoggerConfig loggerConfig = LoggerConfig.createLogger(false, Level.INFO, "testlog4j2refresh", "true", refs,
+ null, config, null);
+ loggerConfig.addAppender(appender, null, null);
+ config.addLogger("testlog4j2refresh", loggerConfig);
+ ctx.stop();
+ ctx.start(config);
+
+ log.error("Info message");
+ }
+
+ @Test
+ public void testRefreshMinimalCodeStart() {
+ Logger log = LogManager.getLogger(this.getClass());
+ final LoggerContext ctx = (LoggerContext) LogManager.getContext(false);
+ final Configuration config = ctx.getConfiguration();
+ ctx.start(config);
+
+ log.error("Info message");
+ }
+
+ @Test
+ public void testRefreshMinimalCodeStopStart() {
+ Logger log = LogManager.getLogger(this.getClass());
+ final LoggerContext ctx = (LoggerContext) LogManager.getContext(false);
+ ctx.stop();
+ ctx.start();
+
+ log.error("Info message");
+ }
+
+ @Test
+ public void testRefreshMinimalCodeStopStartConfig() {
+ Logger log = LogManager.getLogger(this.getClass());
+ final LoggerContext ctx = (LoggerContext) LogManager.getContext(false);
+ final Configuration config = ctx.getConfiguration();
+ ctx.stop();
+ ctx.start(config);
+
+ log.error("Info message");
+ }
+
+ @SuppressWarnings("deprecation")
+ @Test
+ public void testRefreshDeprecatedApis() {
+ Logger log = LogManager.getLogger(this.getClass());
+ final LoggerContext ctx = (LoggerContext) LogManager.getContext(false);
+ final Configuration config = ctx.getConfiguration();
+ PatternLayout layout = PatternLayout.createLayout(PatternLayout.SIMPLE_CONVERSION_PATTERN, null, config, null,
+ null, false, false, null, null);
+ Appender appender = FileAppender.createAppender("target/test.log", "false", "false", "File", "true", "false",
+ "false", "4000", layout, null, "false", null, config);
+ appender.start();
+ config.addAppender(appender);
+ AppenderRef ref = AppenderRef.createAppenderRef("File", null, null);
+ AppenderRef[] refs = new AppenderRef[] { ref };
+ LoggerConfig loggerConfig = LoggerConfig.createLogger("false", Level.INFO, "testlog4j2refresh", "true", refs,
+ null, config, null);
+ loggerConfig.addAppender(appender, null, null);
+ config.addLogger("testlog4j2refresh", loggerConfig);
+ ctx.stop();
+ ctx.start(config);
+
+ log.error("Info message");
+ }
+}
http://git-wip-us.apache.org/repos/asf/logging-log4j2/blob/7b3d22b5/log4j-core/src/test/resources/log4j2-2134.yml
----------------------------------------------------------------------
diff --git a/log4j-core/src/test/resources/log4j2-2134.yml b/log4j-core/src/test/resources/log4j2-2134.yml
new file mode 100644
index 0000000..8254f0f
--- /dev/null
+++ b/log4j-core/src/test/resources/log4j2-2134.yml
@@ -0,0 +1,13 @@
+configuration:
+ name: NUAR_DEFAULT_LOGGING
+ Appenders:
+ Console:
+ name: CONSOLE
+ target: SYSTEM_OUT
+ PatternLayout:
+ pattern: "[%-5level] %d{yyyy-MM-dd HH:mm:ss.SSS} [%t] %c{1} - %msg%n"
+ Loggers:
+ Root:
+ level: info
+ AppenderRef:
+ - ref: "CONSOLE"
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/logging-log4j2/blob/7b3d22b5/src/changes/changes.xml
----------------------------------------------------------------------
diff --git a/src/changes/changes.xml b/src/changes/changes.xml
index cc83489..61b6b11 100644
--- a/src/changes/changes.xml
+++ b/src/changes/changes.xml
@@ -88,6 +88,9 @@
<action issue="LOG4J2-2478" dev="ckozak" type="fix" due-to="Diego Elias Costa">
AbstractStringLayoutStringEncodingBenchmark returns the computed variables on each benchmark to avoid DCE.
</action>
+ <action issue="LOG4J2-2134" dev="ggregory" type="fix" due-to="David del Amo Mateos, Gary Gregory">
+ StackOverflowError at AwaitCompletionReliabilityStrategy.
+ </action>
</release>
<release version="2.11.1" date="2018-07-22" description="GA Release 2.11.1">
<action issue="LOG4J2-2389" dev="rgoers" type="fix" due-to="Liu Wen">