wuqian0808 commented on a change in pull request #593:
URL: https://github.com/apache/logging-log4j2/pull/593#discussion_r745260747
##########
File path:
log4j-core/src/main/java/org/apache/logging/log4j/core/LoggerContext.java
##########
@@ -623,7 +623,12 @@ public Configuration setConfiguration(final Configuration
config) {
map.putIfAbsent("hostName", "unknown");
}
map.putIfAbsent("contextName", contextName);
- config.start();
+ try {
+ config.start();
+ } catch (Exception e) {
+ config.stop();
+ return configuration;
+ }
Review comment:
I will change this part and raise the exception always
##########
File path:
log4j-core/src/test/java/org/apache/logging/log4j/core/config/LoggerContextChangeTest.java
##########
@@ -0,0 +1,69 @@
+package org.apache.logging.log4j.core.config;
+
+import org.apache.logging.log4j.LogManager;
+import org.apache.logging.log4j.Logger;
+import org.junit.Assert;
+import org.junit.jupiter.api.BeforeAll;
+import org.junit.jupiter.api.Test;
+
+import java.io.File;
+import java.util.Set;
+
+public class LoggerContextChangeTest {
+ private static String targetFileName = "log4j2-3182.xml";
+ private static String targetErrorFileName = "log4j2-3182-error.xml";
+ private static String tmpFileName = "log4j2-3182-tmp.xml";
+ private static String destDir = "target/test-classes/";
+
+ @BeforeAll
+ public static void beforeClass() {
+ System.setProperty("log4j2.configurationFile", "classpath:" +
targetFileName);
+ }
+
+
+ @Test
+ public void onChangeTest() {
+ String errorFileName = destDir + targetErrorFileName;
+ String originFileName = destDir + targetFileName;
+ String tmpFile = destDir + tmpFileName;
+ wait(10);
+ updateConfigFileModTime(originFileName, errorFileName, tmpFile);
+ wait(30);
Review comment:
OK. I will reduce this wait time
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]