This is an automated email from the ASF dual-hosted git repository.
rgoers pushed a commit to branch release-2.x
in repository https://gitbox.apache.org/repos/asf/logging-log4j2.git
The following commit(s) were added to refs/heads/release-2.x by this push:
new ca161e7 Revert "LOG4J2-3394 - Allow substitution of system properties
and environment variables in shorthand variables introduced in LOG4J2-3341"
ca161e7 is described below
commit ca161e7e86df696629d5a9404b342ef80a0fcf94
Author: Ralph Goers <[email protected]>
AuthorDate: Sun Feb 6 10:38:37 2022 -0700
Revert "LOG4J2-3394 - Allow substitution of system properties and
environment variables in shorthand variables introduced in LOG4J2-3341"
This reverts commit 6d6ff5b85bbdba8895c41de5c5b6049e07635395.
---
.../properties/PropertiesConfigurationBuilder.java | 8 ++------
.../logging/log4j/core/lookup/Interpolator.java | 14 -------------
.../properties/PropertiesConfigurationTest.java | 22 --------------------
.../log4j/core/lookup/InterpolatorTest.java | 17 ---------------
.../LoggerLevelAppenderTestWithSubst.properties | 24 ----------------------
src/changes/changes.xml | 3 ---
6 files changed, 2 insertions(+), 86 deletions(-)
diff --git
a/log4j-core/src/main/java/org/apache/logging/log4j/core/config/properties/PropertiesConfigurationBuilder.java
b/log4j-core/src/main/java/org/apache/logging/log4j/core/config/properties/PropertiesConfigurationBuilder.java
index 122f88c..bc7c0cd 100644
---
a/log4j-core/src/main/java/org/apache/logging/log4j/core/config/properties/PropertiesConfigurationBuilder.java
+++
b/log4j-core/src/main/java/org/apache/logging/log4j/core/config/properties/PropertiesConfigurationBuilder.java
@@ -38,8 +38,6 @@ import
org.apache.logging.log4j.core.config.builder.api.RootLoggerComponentBuild
import org.apache.logging.log4j.core.config.builder.api.ScriptComponentBuilder;
import
org.apache.logging.log4j.core.config.builder.api.ScriptFileComponentBuilder;
import
org.apache.logging.log4j.core.filter.AbstractFilter.AbstractFilterBuilder;
-import org.apache.logging.log4j.core.lookup.Interpolator;
-import org.apache.logging.log4j.core.lookup.StrSubstitutor;
import org.apache.logging.log4j.core.util.Builder;
import org.apache.logging.log4j.status.StatusLogger;
import org.apache.logging.log4j.util.PropertiesUtil;
@@ -71,7 +69,6 @@ public class PropertiesConfigurationBuilder extends
ConfigurationBuilderFactory
private static final String CONFIG_TYPE = "type";
private final ConfigurationBuilder<PropertiesConfiguration> builder;
- private final StrSubstitutor subst = new StrSubstitutor(new
Interpolator((Properties) null));
private LoggerContext loggerContext;
private Properties rootProperties;
@@ -200,10 +197,9 @@ public class PropertiesConfigurationBuilder extends
ConfigurationBuilderFactory
return builder.build(false);
}
- private void useSyntheticLevelAndAppenderRefs(final String propertyName,
final Properties loggerProps, final Properties context) {
- String propertyValue = (String) context.remove(propertyName);
+ private static void useSyntheticLevelAndAppenderRefs(final String
propertyName, final Properties loggerProps, final Properties context) {
+ final String propertyValue = (String) context.remove(propertyName);
if (propertyValue != null) {
- propertyValue = subst.replace(propertyValue);
final String[] parts = propertyValue.split(",");
if (parts.length > 0) {
final String level = parts[0].trim();
diff --git
a/log4j-core/src/main/java/org/apache/logging/log4j/core/lookup/Interpolator.java
b/log4j-core/src/main/java/org/apache/logging/log4j/core/lookup/Interpolator.java
index 76a6a6c..86a742e 100644
---
a/log4j-core/src/main/java/org/apache/logging/log4j/core/lookup/Interpolator.java
+++
b/log4j-core/src/main/java/org/apache/logging/log4j/core/lookup/Interpolator.java
@@ -21,7 +21,6 @@ import java.util.HashMap;
import java.util.List;
import java.util.Locale;
import java.util.Map;
-import java.util.Properties;
import org.apache.logging.log4j.Logger;
import org.apache.logging.log4j.core.LogEvent;
@@ -95,19 +94,6 @@ public class Interpolator extends
AbstractConfigurationAwareLookup {
}
/**
- * Create a limited Interpolator.
- */
- public Interpolator(final Properties properties) {
- Map<String, String> defaultProps = new HashMap<>();
- if (properties != null) {
- properties.forEach((key, value) ->
defaultProps.put(key.toString(), value.toString()));
- }
- this.defaultLookup = new PropertiesLookup(defaultProps);
- strLookupMap.put("sys", new SystemPropertiesLookup());
- strLookupMap.put("env", new EnvironmentLookup());
- }
-
- /**
* Creates the default Interpolator with the provided properties.
*/
public Interpolator(final Map<String, String> properties) {
diff --git
a/log4j-core/src/test/java/org/apache/logging/log4j/core/config/properties/PropertiesConfigurationTest.java
b/log4j-core/src/test/java/org/apache/logging/log4j/core/config/properties/PropertiesConfigurationTest.java
index 5174283..ec6fcd5 100644
---
a/log4j-core/src/test/java/org/apache/logging/log4j/core/config/properties/PropertiesConfigurationTest.java
+++
b/log4j-core/src/test/java/org/apache/logging/log4j/core/config/properties/PropertiesConfigurationTest.java
@@ -31,7 +31,6 @@ import org.apache.logging.log4j.junit.LoggerContextSource;
import org.apache.logging.log4j.junit.Named;
import org.apache.logging.log4j.test.appender.ListAppender;
import org.junit.jupiter.api.Test;
-import org.junitpioneer.jupiter.SetSystemProperty;
import java.util.List;
import java.util.Map;
@@ -131,25 +130,4 @@ class PropertiesConfigurationTest {
assertEquals(firstEvents, secondEvents);
assertEquals(1, firstEvents.size());
}
-
- @Test
- @LoggerContextSource("LoggerLevelAppenderTestWithSubst.properties")
- void testLoggerLevelAppenderWithSubst(final LoggerContext context, @Named
final ListAppender first, @Named final ListAppender second) {
- context.getLogger(getClass()).atInfo().log("message");
- final List<LogEvent> firstEvents = first.getEvents();
- final List<LogEvent> secondEvents = second.getEvents();
- assertEquals(firstEvents, secondEvents);
- assertEquals(1, firstEvents.size());
- }
-
- @SetSystemProperty(key = "core.config.logger", value = "DEBUG , second")
- @Test
- @LoggerContextSource("LoggerLevelAppenderTestWithSubst.properties")
- void testLoggerLevelAppenderWithSysSubst(final LoggerContext context,
@Named final ListAppender first, @Named final ListAppender second) {
- context.getLogger(getClass()).atInfo().log("message");
- final List<LogEvent> firstEvents = first.getEvents();
- final List<LogEvent> secondEvents = second.getEvents();
- assertEquals(0, firstEvents.size());
- assertEquals(1, secondEvents.size());
- }
}
diff --git
a/log4j-core/src/test/java/org/apache/logging/log4j/core/lookup/InterpolatorTest.java
b/log4j-core/src/test/java/org/apache/logging/log4j/core/lookup/InterpolatorTest.java
index 4294051..456a744 100644
---
a/log4j-core/src/test/java/org/apache/logging/log4j/core/lookup/InterpolatorTest.java
+++
b/log4j-core/src/test/java/org/apache/logging/log4j/core/lookup/InterpolatorTest.java
@@ -21,7 +21,6 @@ import java.util.Collections;
import java.util.Date;
import java.util.HashMap;
import java.util.Map;
-import java.util.Properties;
import org.apache.logging.log4j.Level;
import org.apache.logging.log4j.ThreadContext;
@@ -47,10 +46,6 @@ public class InterpolatorTest {
private static final String TESTKEY = "TestKey";
private static final String TESTKEY2 = "TestKey2";
private static final String TESTVAL = "TestValue";
- private static final String TESTKEY3 = "TestKey3";
- private static final String TESTKEY4 = "TestKey4";
- private static final String TESTVAL3 = "${sys:TestKey4:-default}";
- private static final String TESTVAL4 = "TestVal4";
private static final String TEST_CONTEXT_RESOURCE_NAME =
"logging/context-name";
private static final String TEST_CONTEXT_NAME = "app-1";
@@ -61,8 +56,6 @@ public class InterpolatorTest {
protected void before() throws Throwable {
System.setProperty(TESTKEY, TESTVAL);
System.setProperty(TESTKEY2, TESTVAL);
- System.setProperty(TESTKEY3, TESTVAL3);
- System.setProperty(TESTKEY4, TESTVAL4);
System.setProperty("log4j2.enableJndiLookup", "true");
}
@@ -70,8 +63,6 @@ public class InterpolatorTest {
protected void after() {
System.clearProperty(TESTKEY);
System.clearProperty(TESTKEY2);
- System.clearProperty(TESTKEY3);
- System.clearProperty(TESTKEY4);
System.clearProperty("log4j2.enableJndiLookup");
}
}).around(new JndiRule(
@@ -186,12 +177,4 @@ public class InterpolatorTest {
.build();
assertEquals("mapMessage", interpolator.lookup(event, "map:key"));
}
-
- @Test
- public void testLimited() {
- Interpolator interpolator = new Interpolator((Properties) null);
- String original = "${sys:TestKey3}";
- String result = new StrSubstitutor(interpolator).replace(original);
- assertEquals(TESTVAL3, result);
- }
}
diff --git
a/log4j-core/src/test/resources/LoggerLevelAppenderTestWithSubst.properties
b/log4j-core/src/test/resources/LoggerLevelAppenderTestWithSubst.properties
deleted file mode 100644
index 868e809..0000000
--- a/log4j-core/src/test/resources/LoggerLevelAppenderTestWithSubst.properties
+++ /dev/null
@@ -1,24 +0,0 @@
-#
-# 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.
-#
-
-status = off
-name = LoggerLevelAppenderTest
-logger.core-config-properties.name =
org.apache.logging.log4j.core.config.properties
-# whitespace added for testing trimming
-logger.core-config-properties = ${sys:core.config.logger:-INFO , first ,
second}
-appender.first.type = List
-appender.second.type = List
diff --git a/src/changes/changes.xml b/src/changes/changes.xml
index f88ca08..c59773a 100644
--- a/src/changes/changes.xml
+++ b/src/changes/changes.xml
@@ -209,9 +209,6 @@
AppenderLoggingException logging any exception to a MongoDB Appender.
</action>
<!-- ADD -->
- <action issue="LOG4J2-3394" dev="rgoers" type="fix">
- Allow substitution of system properties and environment variables in
shorthand variables introduced in LOG4J2-3341.
- </action>
<action issue="LOG4J2-2486" dev="rgoers" type="add">
Require log4j2.Script.enableLanguages to be specified to enable
scripting for specific languages.
</action>