You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@logging.apache.org by pk...@apache.org on 2024/08/26 11:51:41 UTC

(logging-log4j2) branch feature/2.x/remove-properties-cache updated (28b46de1d0 -> 78af316935)

This is an automated email from the ASF dual-hosted git repository.

pkarwasz pushed a change to branch feature/2.x/remove-properties-cache
in repository https://gitbox.apache.org/repos/asf/logging-log4j2.git


    omit 28b46de1d0 Replace `ArrayList` with `ConcurrentHashMap`
    omit 6079776e4e Add changelog entry
    omit cd817fb564 Fix tests relying on token-based matching
    omit 7b8d315743 Remove caching from `PropertiesUtil`
     add e6c7f197f2 Disable programmatic configuration if `log4j1.compatibility` is `false`
     add f7d3725202 Fix `JsonLayout` failures under JPMS (#2815)
     add 9fded3e199 Fix links to issues
     add 54924a416e Update `org.apache.maven.surefire:surefire-junit47` to version `3.4.0` (#2862)
     add 7a0057b8ea Update `org.apache.maven:maven-core` to version `3.9.9` (#2861)
     add 24b21b7e10 Update `commons-logging:commons-logging` to version `1.3.4` (#2864)
     add b911bffd0e Update `org.apache.commons:commons-compress` to version `1.27.1` (#2869)
     add a50366052a Update `com.google.guava:guava` to version `33.3.0-jre` (#2860)
     add f141d9490f Bump org.slf4j:slf4j-api from 2.0.9 to 2.0.16
     add 6d74d4bbf7 Update `de.flapdoodle.reverse:de.flapdoodle.reverse` to version `1.8.0` (#2881)
     add 67848c1fc2 Update `org.jmdns:jmdns` to version `3.5.12` (#2879)
     add 615092bc9c Disable SLF4J major upgrades
     add 6fb4f90b87 Disable level modification via JUL by default
     add f5ddc79089 Document module deprecation in 2.x
     new 78af316935 Remove caching from `PropertiesUtil` (+#2849 review)

This update added new revisions after undoing existing revisions.
That is to say, some revisions that were in the old version of the
branch are not in the new version.  This situation occurs
when a user --force pushes a change and generates a repository
containing something like this:

 * -- * -- B -- O -- O -- O   (28b46de1d0)
            \
             N -- N -- N   refs/heads/feature/2.x/remove-properties-cache (78af316935)

You should already have received notification emails for all of the O
revisions, and so the following emails describe only the N revisions
from the common base, B.

Any revisions marked "omit" are not gone; other references still
refer to them.  Any revisions marked "discard" are gone forever.

The 1 revisions listed above as "new" are entirely new to this
repository and will be described in separate emails.  The revisions
listed as "add" were already present in the repository and have only
been added to this reference.


Summary of changes:
 .github/dependabot.yaml                            |   3 +
 antora-playbook.yaml                               |   5 +-
 .../org/apache/log4j/PropertyConfigurator.java     | 212 +++++++++------------
 .../java/org/apache/log4j/xml/DOMConfigurator.java |  96 ++++++----
 .../org/apache/log4j/PropertyConfiguratorTest.java | 121 +++++-------
 .../java/org/apache/log4j/xml/DOMTestCase.java     |  60 ++++--
 .../input/xml => DOMTestCase}/DOMTest4.xml         |   4 +-
 .../input/xml => DOMTestCase}/DOMTest4_A1.xml      |   0
 .../input/xml => DOMTestCase}/DOMTest4_A2.xml      |   0
 .../input/xml => DOMTestCase}/DOMTestCase1.xml     |   0
 .../input/xml => DOMTestCase}/categoryfactory1.xml |   0
 .../input/xml => DOMTestCase}/categoryfactory2.xml |   0
 .../input/xml => DOMTestCase}/defaultInit.xml      |   0
 .../input/xml => DOMTestCase}/loggerfactory1.xml   |   0
 .../input/xml => DOMTestCase}/testReset.xml        |   0
 .../xml => DOMTestCase}/throwableRenderer1.xml     |   0
 .../PropertyConfiguratorTest/badEscape.properties  |   4 +-
 .../filter.properties}                             |   2 +-
 .../input/xml/SocketAppenderTestConfig.xml         |  59 ------
 .../log4j1-1.2.17/input/xml/customLevel1.xml       |  34 ----
 .../log4j1-1.2.17/input/xml/customLevel2.xml       |  41 ----
 .../log4j1-1.2.17/input/xml/customLevel3.xml       |  44 -----
 .../log4j1-1.2.17/input/xml/customLevel4.xml       |  35 ----
 .../log4j1-1.2.17/input/xml/customLogger1.xml      |  35 ----
 .../log4j1-1.2.17/input/xml/customLogger2.xml      |  43 -----
 .../log4j1-1.2.17/input/xml/customLogger3.xml      |  35 ----
 .../log4j1-1.2.17/input/xml/fallback1.xml          |  50 -----
 .../log4j1-1.2.17/input/xml/smtpAppender1.xml      |  38 ----
 log4j-core-its/pom.xml                             |   2 +-
 .../ContextDataAsEntryListDeserializer.java        |   9 +-
 .../jackson/ContextDataAsEntryListSerializer.java  |   3 +-
 .../core/jackson/ContextDataDeserializer.java      |   9 +-
 .../log4j/core/jackson/ContextDataSerializer.java  |   3 +-
 .../logging/log4j/core/jackson/Initializers.java   |  63 +++---
 .../logging/log4j/core/jackson/JsonConstants.java  |  10 +
 .../log4j/core/jackson/Log4jJsonModule.java        |   8 +-
 .../logging/log4j/core/jackson/Log4jXmlModule.java |   4 +-
 .../log4j/core/jackson/Log4jYamlModule.java        |   6 +-
 .../log4j/core/jackson/LogEventJsonMixIn.java      | 165 ----------------
 ...ithContextListMixIn.java => LogEventMixIn.java} |  81 ++++----
 .../logging/log4j/core/jackson/MapEntry.java       |   2 +-
 .../logging/log4j/core/jackson/package-info.java   |   2 +-
 .../org/apache/logging/log4j/jul/LogManager.java   |  19 +-
 .../logging/log4j/jul/test/ApiLoggerTest.java      |  16 +-
 .../logging/log4j/jul/test/CoreLoggerTest.java     |   4 +
 log4j-parent/pom.xml                               |  14 +-
 log4j-perf-test/pom.xml                            |   2 +-
 log4j-slf4j2-impl/pom.xml                          |   2 +-
 log4j-to-slf4j/pom.xml                             |   2 +-
 pom.xml                                            |   6 +-
 .../.2.x.x/1963_add_logging_to_properties_util.xml |   2 +-
 ...iptor_warnings.xml => 2353_set_level_no-op.xml} |   4 +-
 .../2778_configurator_no_op.xml}                   |   4 +-
 .../2814_open_json_layout.xml}                     |   3 +-
 src/changelog/.2.x.x/add_log4j_mongodb.xml         |   1 +
 src/changelog/.2.x.x/change-is-webapp.xml          |   1 +
 .../.2.x.x/deprecate-Message-getFormat.xml         |   1 +
 src/changelog/.2.x.x/deprecate_EventLogger.xml     |   1 +
 src/changelog/.2.x.x/deprecate_duration.xml        |   1 +
 .../deprecate_log4j2_default_status_level.xml      |   1 +
 src/changelog/.2.x.x/deprecate_log4j_mongodb4.xml  |   1 +
 src/changelog/.2.x.x/remove_log4j_mongodb3.xml     |   1 +
 .../.2.x.x/update_com_google_guava_guava.xml       |   4 +-
 .../update_commons_logging_commons_logging.xml     |   4 +-
 ...de_flapdoodle_reverse_de_flapdoodle_reverse.xml |   4 +-
 .../update_org_apache_commons_commons_compress.xml |   4 +-
 .../.2.x.x/update_org_apache_maven_maven_core.xml  |   4 +-
 ..._org_apache_maven_surefire_surefire_junit47.xml |   4 +-
 src/changelog/.2.x.x/update_org_jmdns_jmdns.xml    |   4 +-
 ..._mongodb.xml => update_org_slf4j_slf4j_api.xml} |   3 +-
 src/site/antora/modules/ROOT/pages/jakarta.adoc    |   6 +
 .../ROOT/pages/manual/appenders/database.adoc      |  10 +
 .../ROOT/pages/manual/appenders/message-queue.adoc |   9 +
 .../appender-deprecation.adoc}                     |   9 +-
 .../systemproperties/properties-log4j-jul.adoc     |  21 +-
 75 files changed, 458 insertions(+), 1002 deletions(-)
 rename log4j-1.2-api/src/test/resources/{log4j1-1.2.17/input/xml => DOMTestCase}/DOMTest4.xml (92%)
 rename log4j-1.2-api/src/test/resources/{log4j1-1.2.17/input/xml => DOMTestCase}/DOMTest4_A1.xml (100%)
 rename log4j-1.2-api/src/test/resources/{log4j1-1.2.17/input/xml => DOMTestCase}/DOMTest4_A2.xml (100%)
 rename log4j-1.2-api/src/test/resources/{log4j1-1.2.17/input/xml => DOMTestCase}/DOMTestCase1.xml (100%)
 rename log4j-1.2-api/src/test/resources/{log4j1-1.2.17/input/xml => DOMTestCase}/categoryfactory1.xml (100%)
 rename log4j-1.2-api/src/test/resources/{log4j1-1.2.17/input/xml => DOMTestCase}/categoryfactory2.xml (100%)
 rename log4j-1.2-api/src/test/resources/{log4j1-1.2.17/input/xml => DOMTestCase}/defaultInit.xml (100%)
 rename log4j-1.2-api/src/test/resources/{log4j1-1.2.17/input/xml => DOMTestCase}/loggerfactory1.xml (100%)
 rename log4j-1.2-api/src/test/resources/{log4j1-1.2.17/input/xml => DOMTestCase}/testReset.xml (100%)
 rename log4j-1.2-api/src/test/resources/{log4j1-1.2.17/input/xml => DOMTestCase}/throwableRenderer1.xml (100%)
 copy log4j-api-test/src/test/resources/log4j2.system.properties => log4j-1.2-api/src/test/resources/PropertyConfiguratorTest/badEscape.properties (92%)
 rename log4j-1.2-api/src/test/resources/{log4j1-1.2.17/input/filter1.properties => PropertyConfiguratorTest/filter.properties} (98%)
 delete mode 100644 log4j-1.2-api/src/test/resources/log4j1-1.2.17/input/xml/SocketAppenderTestConfig.xml
 delete mode 100644 log4j-1.2-api/src/test/resources/log4j1-1.2.17/input/xml/customLevel1.xml
 delete mode 100644 log4j-1.2-api/src/test/resources/log4j1-1.2.17/input/xml/customLevel2.xml
 delete mode 100644 log4j-1.2-api/src/test/resources/log4j1-1.2.17/input/xml/customLevel3.xml
 delete mode 100644 log4j-1.2-api/src/test/resources/log4j1-1.2.17/input/xml/customLevel4.xml
 delete mode 100644 log4j-1.2-api/src/test/resources/log4j1-1.2.17/input/xml/customLogger1.xml
 delete mode 100644 log4j-1.2-api/src/test/resources/log4j1-1.2.17/input/xml/customLogger2.xml
 delete mode 100644 log4j-1.2-api/src/test/resources/log4j1-1.2.17/input/xml/customLogger3.xml
 delete mode 100644 log4j-1.2-api/src/test/resources/log4j1-1.2.17/input/xml/fallback1.xml
 delete mode 100644 log4j-1.2-api/src/test/resources/log4j1-1.2.17/input/xml/smtpAppender1.xml
 delete mode 100644 log4j-core/src/main/java/org/apache/logging/log4j/core/jackson/LogEventJsonMixIn.java
 rename log4j-core/src/main/java/org/apache/logging/log4j/core/jackson/{LogEventWithContextListMixIn.java => LogEventMixIn.java} (73%)
 copy src/changelog/.2.x.x/{2835_improve_plugin_descriptor_warnings.xml => 2353_set_level_no-op.xml} (63%)
 copy src/changelog/{2.0-beta3/LOG4J2-29_Added_font_and_fontSize_parameters_to_HTMLLayout_Replace_ne.xml => .2.x.x/2778_configurator_no_op.xml} (59%)
 copy src/changelog/{2.0-beta2/DefaultConfiguration_was_not_starting_the_Console_Appender.xml => .2.x.x/2814_open_json_layout.xml} (64%)
 copy src/changelog/.2.x.x/{add_log4j_mongodb.xml => update_org_slf4j_slf4j_api.xml} (63%)
 copy src/site/antora/modules/ROOT/partials/{features/config-properties.adoc => manual/appender-deprecation.adoc} (76%)


(logging-log4j2) 01/01: Remove caching from `PropertiesUtil` (+#2849 review)

Posted by pk...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

pkarwasz pushed a commit to branch feature/2.x/remove-properties-cache
in repository https://gitbox.apache.org/repos/asf/logging-log4j2.git

commit 78af3169351a2ba059cc7d98d21042c6497027e6
Author: Piotr P. Karwasz <pi...@karwasz.org>
AuthorDate: Fri Jun 28 15:35:58 2024 +0200

    Remove caching from `PropertiesUtil` (+#2849 review)
    
    The `PropertiesUtil` class preemptively caches lookups for all known keys from enumerable property sources.
    On my Debian system a JVM has around 60 among environment variables and system properties, which causes `PropertiesUtil` to perform around 60 lookups for **each** of the 3 standard property sources. Most of these properties have nothing to do with Log4j.
    
    On the other hand all Log4j artifacts use no more than 100 configuration properties and the results of most of those calls are cache in static fields.
    
    This PR removes the property value caches used by `PropertiesUtil`.
    The change should have no noticeable impact on the loading time of Log4j Core, while at the same time simplifies the system.
---
 .../log4j/util/PropertiesUtilOrderTest.java        |  53 ++-------
 .../logging/log4j/util/PropertiesUtilTest.java     |  22 ++--
 .../src/test/resources/Jira3413Test.properties     |  18 +--
 .../apache/logging/log4j/util/PropertiesUtil.java  | 130 +++++----------------
 .../async/AsyncQueueFullPolicyFactoryTest.java     |   2 -
 .../core/impl/ThreadContextDataInjectorTest.java   |   2 -
 .../core/net/ssl/SslConfigurationFactoryTest.java  |   3 -
 .../appender/db/jpa/AbstractJpaAppenderTest.java   |   3 -
 .../.2.x.x/2849-remove-token-based-matching.xml    |   8 ++
 9 files changed, 67 insertions(+), 174 deletions(-)

diff --git a/log4j-api-test/src/test/java/org/apache/logging/log4j/util/PropertiesUtilOrderTest.java b/log4j-api-test/src/test/java/org/apache/logging/log4j/util/PropertiesUtilOrderTest.java
index 4343d9618f..662bfcd1cc 100644
--- a/log4j-api-test/src/test/java/org/apache/logging/log4j/util/PropertiesUtilOrderTest.java
+++ b/log4j-api-test/src/test/java/org/apache/logging/log4j/util/PropertiesUtilOrderTest.java
@@ -35,9 +35,9 @@ import uk.org.webcompere.systemstubs.properties.SystemProperties;
 
 @ExtendWith(SystemStubsExtension.class)
 @ResourceLock(value = Resources.SYSTEM_PROPERTIES)
-public class PropertiesUtilOrderTest {
+class PropertiesUtilOrderTest {
 
-    public static class NonEnumerablePropertySource implements PropertySource {
+    private static class NonEnumerablePropertySource implements PropertySource {
 
         private final Properties props;
 
@@ -67,14 +67,6 @@ public class PropertiesUtilOrderTest {
         }
     }
 
-    public static class NullPropertySource implements PropertySource {
-
-        @Override
-        public int getPriority() {
-            return Integer.MIN_VALUE;
-        }
-    }
-
     private final Properties properties = new Properties();
 
     @BeforeEach
@@ -85,7 +77,7 @@ public class PropertiesUtilOrderTest {
     }
 
     @Test
-    public void testNormalizedOverrideLegacy() {
+    void testNormalizedOverrideLegacy() {
         final PropertiesUtil util = new PropertiesUtil(properties);
         final String legacy = "props.legacy";
         final String normalized = "props.normalized";
@@ -104,20 +96,7 @@ public class PropertiesUtilOrderTest {
     }
 
     @Test
-    public void testFallsBackToTokenMatching() {
-        final PropertiesUtil util = new PropertiesUtil(properties);
-        for (int i = 1; i <= 4; i++) {
-            final String key = "log4j2.tokenBasedProperty" + i;
-            assertTrue(util.hasProperty(key));
-            assertEquals("props.token", util.getStringProperty(key));
-        }
-        // No fall back (a normalized property is present)
-        assertTrue(util.hasProperty("log4j2.normalizedProperty"));
-        assertEquals("props.normalized", util.getStringProperty("log4j2.normalizedProperty"));
-    }
-
-    @Test
-    public void testOrderOfNormalizedProperties(final EnvironmentVariables env, final SystemProperties sysProps) {
+    void testOrderOfNormalizedProperties(final EnvironmentVariables env, final SystemProperties sysProps) {
         properties.remove("log4j2.normalizedProperty");
         properties.remove("LOG4J_normalized.property");
         final PropertiesUtil util = new PropertiesUtil(properties);
@@ -128,21 +107,18 @@ public class PropertiesUtilOrderTest {
         assertEquals(null, util.getStringProperty("log4j2.normalizedProperty"));
 
         properties.setProperty("log4j2.normalizedProperty", "props.normalized");
-        util.reload();
         assertTrue(util.hasProperty("Log4jNormalizedProperty"));
         assertEquals("props.normalized", util.getStringProperty("Log4jNormalizedProperty"));
         assertTrue(util.hasProperty("log4j2.normalizedProperty"));
         assertEquals("props.normalized", util.getStringProperty("log4j2.normalizedProperty"));
 
         env.set("LOG4J_NORMALIZED_PROPERTY", "env");
-        util.reload();
         assertTrue(util.hasProperty("Log4jNormalizedProperty"));
         assertEquals("env", util.getStringProperty("Log4jNormalizedProperty"));
         assertTrue(util.hasProperty("log4j2.normalizedProperty"));
         assertEquals("env", util.getStringProperty("log4j2.normalizedProperty"));
 
         sysProps.set("log4j2.normalizedProperty", "sysProps");
-        util.reload();
         assertTrue(util.hasProperty("Log4jNormalizedProperty"));
         assertEquals("sysProps", util.getStringProperty("Log4jNormalizedProperty"));
         assertTrue(util.hasProperty("log4j2.normalizedProperty"));
@@ -150,7 +126,7 @@ public class PropertiesUtilOrderTest {
     }
 
     @Test
-    public void testLegacySystemPropertyHasHigherPriorityThanEnv(
+    void testLegacySystemPropertyHasHigherPriorityThanEnv(
             final EnvironmentVariables env, final SystemProperties sysProps) {
         env.set("LOG4J_CONFIGURATION_FILE", "env");
         final PropertiesUtil util = new PropertiesUtil(properties);
@@ -159,18 +135,16 @@ public class PropertiesUtilOrderTest {
         assertEquals("env", util.getStringProperty("log4j.configurationFile"));
 
         sysProps.set("log4j.configurationFile", "legacy");
-        util.reload();
         assertTrue(util.hasProperty("log4j.configurationFile"));
         assertEquals("legacy", util.getStringProperty("log4j.configurationFile"));
 
         sysProps.set("log4j2.configurationFile", "new");
-        util.reload();
         assertTrue(util.hasProperty("log4j.configurationFile"));
         assertEquals("new", util.getStringProperty("log4j.configurationFile"));
     }
 
     @Test
-    public void testHighPriorityNonEnumerableSource(final SystemProperties sysProps) {
+    void testHighPriorityNonEnumerableSource(final SystemProperties sysProps) {
         // In both datasources
         assertNotNull(properties.getProperty("log4j2.normalizedProperty"));
         assertNotNull(properties.getProperty("log4j.onlyLegacy"));
@@ -201,22 +175,19 @@ public class PropertiesUtilOrderTest {
     }
 
     /**
-     * Checks the for missing null checks. The {@link NullPropertySource} returns
+     * Checks the for missing null checks, using a {@link PropertySource}, which returns
      * {@code null} in almost every call.
-     *
-     * @param sysProps
      */
     @Test
-    public void testNullChecks(final SystemProperties sysProps) {
+    void testNullChecks(final SystemProperties sysProps) {
         sysProps.set("log4j2.someProperty", "sysProps");
         sysProps.set("Log4jLegacyProperty", "sysProps");
-        final PropertiesUtil util = new PropertiesUtil(new NullPropertySource());
-        assertTrue(util.hasProperty("log4j2.someProperty"));
-        assertEquals("sysProps", util.getStringProperty("log4j2.someProperty"));
+        final PropertiesUtil util = new PropertiesUtil(() -> Integer.MIN_VALUE);
+
+        assertTrue(util.hasProperty("Log4jSomeProperty"));
+        assertEquals("sysProps", util.getStringProperty("log4jSomeProperty"));
         assertTrue(util.hasProperty("Log4jLegacyProperty"));
         assertEquals("sysProps", util.getStringProperty("Log4jLegacyProperty"));
-        assertTrue(util.hasProperty("log4j.legacyProperty"));
-        assertEquals("sysProps", util.getStringProperty("log4j.legacyProperty"));
         assertFalse(util.hasProperty("log4j2.nonExistentProperty"));
         assertNull(util.getStringProperty("log4j2.nonExistentProperty"));
     }
diff --git a/log4j-api-test/src/test/java/org/apache/logging/log4j/util/PropertiesUtilTest.java b/log4j-api-test/src/test/java/org/apache/logging/log4j/util/PropertiesUtilTest.java
index 230d8d15cf..a655959765 100644
--- a/log4j-api-test/src/test/java/org/apache/logging/log4j/util/PropertiesUtilTest.java
+++ b/log4j-api-test/src/test/java/org/apache/logging/log4j/util/PropertiesUtilTest.java
@@ -212,15 +212,15 @@ class PropertiesUtilTest {
         {null, "org.apache.logging.log4j.level"},
         {null, "Log4jAnotherProperty"},
         {null, "log4j2.catalinaBase"},
-        {"ok", "log4j2.configurationFile"},
-        {"ok", "log4j2.defaultStatusLevel"},
-        {"ok", "log4j2.newLevel"},
-        {"ok", "log4j2.asyncLoggerTimeout"},
-        {"ok", "log4j2.asyncLoggerConfigRingBufferSize"},
-        {"ok", "log4j2.disableThreadContext"},
-        {"ok", "log4j2.disableThreadContextStack"},
-        {"ok", "log4j2.disableThreadContextMap"},
-        {"ok", "log4j2.isThreadContextMapInheritable"}
+        {"ok", "log4j.configurationFile"},
+        {"ok", "Log4jDefaultStatusLevel"},
+        {"ok", "org.apache.logging.log4j.newLevel"},
+        {"ok", "AsyncLogger.Timeout"},
+        {"ok", "AsyncLoggerConfig.RingBufferSize"},
+        {"ok", "disableThreadContext"},
+        {"ok", "disableThreadContextStack"},
+        {"ok", "disableThreadContextMap"},
+        {"ok", "isThreadContextMapInheritable"}
     };
 
     /**
@@ -232,7 +232,9 @@ class PropertiesUtilTest {
     void testResolvesOnlyLog4jProperties() {
         final PropertiesUtil util = new PropertiesUtil("Jira3413Test.properties");
         for (final String[] pair : data) {
-            assertEquals(pair[0], util.getStringProperty(pair[1]));
+            assertThat(util.getStringProperty(pair[1]))
+                    .as("Checking property %s", pair[1])
+                    .isEqualTo(pair[0]);
         }
     }
 
diff --git a/log4j-api-test/src/test/resources/Jira3413Test.properties b/log4j-api-test/src/test/resources/Jira3413Test.properties
index 371cca0894..6932845e3f 100644
--- a/log4j-api-test/src/test/resources/Jira3413Test.properties
+++ b/log4j-api-test/src/test/resources/Jira3413Test.properties
@@ -21,14 +21,14 @@ another.property=fail
 catalina.base=fail
 
 # Some legacy properties with a characteristic prefix
-log4j.configurationFile=ok
-Log4jDefaultStatusLevel=ok
-org.apache.logging.log4j.newLevel=ok
+log4j2.configurationFile=ok
+log4j2.defaultStatusLevel=ok
+log4j2.newLevel=ok
 
 # No characteristic prefix
-AsyncLogger.Timeout=ok
-AsyncLoggerConfig.RingBufferSize=ok
-disableThreadContext=ok
-disableThreadContextStack=ok
-disableThreadContextMap=ok
-isThreadContextMapInheritable=ok
+log4j2.asyncLoggerTimeout=ok
+log4j2.asyncLoggerConfigRingBufferSize=ok
+log4j2.disableThreadContext=ok
+log4j2.disableThreadContextStack=ok
+log4j2.disableThreadContextMap=ok
+log4j2.isThreadContextMapInheritable=ok
diff --git a/log4j-api/src/main/java/org/apache/logging/log4j/util/PropertiesUtil.java b/log4j-api/src/main/java/org/apache/logging/log4j/util/PropertiesUtil.java
index fdcee68eb8..8b4baf4e53 100644
--- a/log4j-api/src/main/java/org/apache/logging/log4j/util/PropertiesUtil.java
+++ b/log4j-api/src/main/java/org/apache/logging/log4j/util/PropertiesUtil.java
@@ -27,7 +27,7 @@ import java.time.temporal.ChronoUnit;
 import java.time.temporal.TemporalUnit;
 import java.util.ArrayList;
 import java.util.Arrays;
-import java.util.HashSet;
+import java.util.Collection;
 import java.util.List;
 import java.util.Map;
 import java.util.Objects;
@@ -36,16 +36,12 @@ import java.util.ResourceBundle;
 import java.util.ServiceLoader;
 import java.util.Set;
 import java.util.concurrent.ConcurrentHashMap;
-import java.util.concurrent.locks.Lock;
-import java.util.concurrent.locks.ReadWriteLock;
-import java.util.concurrent.locks.ReentrantReadWriteLock;
 import java.util.regex.Matcher;
 import java.util.regex.Pattern;
 import java.util.stream.Collectors;
 import java.util.stream.Stream;
 import org.apache.logging.log4j.Logger;
 import org.apache.logging.log4j.status.StatusLogger;
-import org.apache.logging.log4j.util.PropertySource.Comparator;
 
 /**
  * <em>Consider this class private.</em>
@@ -104,7 +100,7 @@ public final class PropertiesUtil {
      * @param source a property source
      */
     PropertiesUtil(final PropertySource source) {
-        this.environment = new Environment(source);
+        environment = new Environment(source);
     }
 
     /**
@@ -479,10 +475,10 @@ public final class PropertiesUtil {
      * Reloads all properties. This is primarily useful for unit tests.
      *
      * @since 2.10.0
+     * @deprecated since 2.24.0 caching of property values is disabled.
      */
-    public void reload() {
-        environment.reload();
-    }
+    @Deprecated
+    public void reload() {}
 
     /**
      * Provides support for looking up global configuration properties via environment variables, property files,
@@ -499,17 +495,7 @@ public final class PropertiesUtil {
      */
     private static final class Environment {
 
-        private final List<PropertySource> sources = new ArrayList<>();
-        private final ReadWriteLock sourceLock = new ReentrantReadWriteLock();
-        private final Lock sourceReadLock = sourceLock.readLock();
-        private final Lock sourceWriteLock = sourceLock.writeLock();
-
-        /**
-         * Maps a key to its value or the value of its normalization in the lowest priority source that contains it.
-         */
-        private final Map<String, String> literal = new ConcurrentHashMap<>();
-
-        private final Map<List<CharSequence>, String> tokenized = new ConcurrentHashMap<>();
+        private final Set<PropertySource> sources = ConcurrentHashMap.newKeySet();
 
         private Environment(final PropertySource propertySource) {
             final PropertySource sysProps = new PropertyFilePropertySource(LOG4J_SYSTEM_PROPERTIES_FILE_NAME, false);
@@ -532,89 +518,32 @@ public final class PropertiesUtil {
                             ServiceLoader.load(PropertySource.class, PropertiesUtil.class.getClassLoader()),
                             LOGGER)
                     .forEach(sources::add);
-            sources.sort(Comparator.INSTANCE);
-
-            reload();
         }
 
         private void addPropertySource(final PropertySource propertySource) {
-            sourceWriteLock.lock();
-            try {
-                if (!sources.contains(propertySource)) {
-                    sources.add(propertySource);
-                    sources.sort(Comparator.INSTANCE);
-                }
-            } finally {
-                sourceWriteLock.unlock();
-            }
+            sources.add(propertySource);
         }
 
         private void removePropertySource(final PropertySource propertySource) {
-            sourceWriteLock.lock();
-            try {
-                sources.remove(propertySource);
-            } finally {
-                sourceWriteLock.unlock();
-            }
+            sources.remove(propertySource);
         }
 
-        private void reload() {
-            literal.clear();
-            tokenized.clear();
-            sourceWriteLock.lock();
-            try {
-                // 1. Collects all property keys from enumerable sources.
-                final Set<String> keys = new HashSet<>();
-                sources.stream().map(PropertySource::getPropertyNames).forEach(keys::addAll);
-                // 2. Fills the property caches. Sources with higher priority values don't override the previous ones.
-                keys.stream().filter(Strings::isNotBlank).forEach(key -> {
-                    final List<CharSequence> tokens = PropertySource.Util.tokenize(key);
-                    final boolean hasTokens = !tokens.isEmpty();
-                    sources.forEach(source -> {
-                        if (sourceContainsProperty(source, key)) {
-                            final String value = sourceGetProperty(source, key);
-                            if (hasTokens) {
-                                tokenized.putIfAbsent(tokens, value);
-                            }
-                        }
-                        if (hasTokens) {
+        private String get(final String key) {
+            final List<CharSequence> tokens = PropertySource.Util.tokenize(key);
+            return sources.stream()
+                    .sorted(PropertySource.Comparator.INSTANCE)
+                    .map(source -> {
+                        if (!tokens.isEmpty()) {
                             final String normalKey = Objects.toString(source.getNormalForm(tokens), null);
                             if (normalKey != null && sourceContainsProperty(source, normalKey)) {
-                                literal.putIfAbsent(key, sourceGetProperty(source, normalKey));
-                            } else if (sourceContainsProperty(source, key)) {
-                                literal.putIfAbsent(key, sourceGetProperty(source, key));
+                                return sourceGetProperty(source, normalKey);
                             }
                         }
-                    });
-                });
-            } finally {
-                sourceWriteLock.unlock();
-            }
-        }
-
-        private String get(final String key) {
-            if (literal.containsKey(key)) {
-                return literal.get(key);
-            }
-            final List<CharSequence> tokens = PropertySource.Util.tokenize(key);
-            final boolean hasTokens = !tokens.isEmpty();
-            sourceReadLock.lock();
-            try {
-                for (final PropertySource source : sources) {
-                    if (hasTokens) {
-                        final String normalKey = Objects.toString(source.getNormalForm(tokens), null);
-                        if (normalKey != null && sourceContainsProperty(source, normalKey)) {
-                            return sourceGetProperty(source, normalKey);
-                        }
-                    }
-                    if (sourceContainsProperty(source, key)) {
                         return sourceGetProperty(source, key);
-                    }
-                }
-            } finally {
-                sourceReadLock.unlock();
-            }
-            return tokenized.get(tokens);
+                    })
+                    .filter(Objects::nonNull)
+                    .findFirst()
+                    .orElse(null);
         }
 
         private boolean sourceContainsProperty(final PropertySource source, final String key) {
@@ -637,18 +566,11 @@ public final class PropertiesUtil {
 
         private boolean containsKey(final String key) {
             final List<CharSequence> tokens = PropertySource.Util.tokenize(key);
-            sourceReadLock.lock();
-            try {
-                return literal.containsKey(key)
-                        || tokenized.containsKey(tokens)
-                        || sources.stream().anyMatch(s -> {
-                            final CharSequence normalizedKey = s.getNormalForm(tokens);
-                            return sourceContainsProperty(s, key)
-                                    || (normalizedKey != null && sourceContainsProperty(s, normalizedKey.toString()));
-                        });
-            } finally {
-                sourceReadLock.unlock();
-            }
+            return sources.stream().anyMatch(s -> {
+                final CharSequence normalizedKey = tokens.isEmpty() ? null : s.getNormalForm(tokens);
+                return sourceContainsProperty(s, key)
+                        || (normalizedKey != null && sourceContainsProperty(s, normalizedKey.toString()));
+            });
         }
     }
 
@@ -663,13 +585,13 @@ public final class PropertiesUtil {
     public static Properties extractSubset(final Properties properties, final String prefix) {
         final Properties subset = new Properties();
 
-        if (prefix == null || prefix.length() == 0) {
+        if (prefix == null || prefix.isEmpty()) {
             return subset;
         }
 
         final String prefixToMatch = prefix.charAt(prefix.length() - 1) != '.' ? prefix + '.' : prefix;
 
-        final List<String> keys = new ArrayList<>();
+        final Collection<String> keys = new ArrayList<>();
 
         for (final String key : properties.stringPropertyNames()) {
             if (key.startsWith(prefixToMatch)) {
diff --git a/log4j-core-test/src/test/java/org/apache/logging/log4j/core/async/AsyncQueueFullPolicyFactoryTest.java b/log4j-core-test/src/test/java/org/apache/logging/log4j/core/async/AsyncQueueFullPolicyFactoryTest.java
index 06f6f06384..37f4a77c81 100644
--- a/log4j-core-test/src/test/java/org/apache/logging/log4j/core/async/AsyncQueueFullPolicyFactoryTest.java
+++ b/log4j-core-test/src/test/java/org/apache/logging/log4j/core/async/AsyncQueueFullPolicyFactoryTest.java
@@ -21,7 +21,6 @@ import static org.junit.Assert.assertEquals;
 
 import org.apache.logging.log4j.Level;
 import org.apache.logging.log4j.core.test.categories.AsyncLoggers;
-import org.apache.logging.log4j.util.PropertiesUtil;
 import org.junit.After;
 import org.junit.Before;
 import org.junit.Test;
@@ -38,7 +37,6 @@ public class AsyncQueueFullPolicyFactoryTest {
     public void resetProperties() throws Exception {
         System.clearProperty(AsyncQueueFullPolicyFactory.PROPERTY_NAME_ASYNC_EVENT_ROUTER);
         System.clearProperty(AsyncQueueFullPolicyFactory.PROPERTY_NAME_DISCARDING_THRESHOLD_LEVEL);
-        PropertiesUtil.getProperties().reload();
     }
 
     @Test
diff --git a/log4j-core-test/src/test/java/org/apache/logging/log4j/core/impl/ThreadContextDataInjectorTest.java b/log4j-core-test/src/test/java/org/apache/logging/log4j/core/impl/ThreadContextDataInjectorTest.java
index 39258f5003..ff4211ca29 100644
--- a/log4j-core-test/src/test/java/org/apache/logging/log4j/core/impl/ThreadContextDataInjectorTest.java
+++ b/log4j-core-test/src/test/java/org/apache/logging/log4j/core/impl/ThreadContextDataInjectorTest.java
@@ -35,7 +35,6 @@ import org.apache.logging.log4j.ThreadContext;
 import org.apache.logging.log4j.core.ContextDataInjector;
 import org.apache.logging.log4j.spi.ReadOnlyThreadContextMap;
 import org.apache.logging.log4j.test.ThreadContextUtilityClass;
-import org.apache.logging.log4j.util.PropertiesUtil;
 import org.apache.logging.log4j.util.SortedArrayStringMap;
 import org.apache.logging.log4j.util.StringMap;
 import org.junit.After;
@@ -122,7 +121,6 @@ public class ThreadContextDataInjectorTest {
 
     private void prepareThreadContext(final boolean isThreadContextMapInheritable) {
         System.setProperty("log4j2.isThreadContextMapInheritable", Boolean.toString(isThreadContextMapInheritable));
-        PropertiesUtil.getProperties().reload();
         ThreadContextUtilityClass.reset();
         ThreadContext.remove("baz");
         ThreadContext.put("foo", "bar");
diff --git a/log4j-core-test/src/test/java/org/apache/logging/log4j/core/net/ssl/SslConfigurationFactoryTest.java b/log4j-core-test/src/test/java/org/apache/logging/log4j/core/net/ssl/SslConfigurationFactoryTest.java
index 53e3f118cb..0492ef0bb2 100644
--- a/log4j-core-test/src/test/java/org/apache/logging/log4j/core/net/ssl/SslConfigurationFactoryTest.java
+++ b/log4j-core-test/src/test/java/org/apache/logging/log4j/core/net/ssl/SslConfigurationFactoryTest.java
@@ -58,7 +58,6 @@ public class SslConfigurationFactoryTest {
         // Only keystore
         props.clear();
         addKeystoreConfiguration(props);
-        util.reload();
         sslConfiguration = SslConfigurationFactory.createSslConfiguration(util);
         assertNotNull(sslConfiguration);
         assertNotNull(sslConfiguration.getKeyStoreConfig());
@@ -66,7 +65,6 @@ public class SslConfigurationFactoryTest {
         // Only truststore
         props.clear();
         addTruststoreConfiguration(props);
-        util.reload();
         sslConfiguration = SslConfigurationFactory.createSslConfiguration(util);
         assertNotNull(sslConfiguration);
         assertNull(sslConfiguration.getKeyStoreConfig());
@@ -75,7 +73,6 @@ public class SslConfigurationFactoryTest {
         props.clear();
         addKeystoreConfiguration(props);
         addTruststoreConfiguration(props);
-        util.reload();
         sslConfiguration = SslConfigurationFactory.createSslConfiguration(util);
         assertNotNull(sslConfiguration);
         assertNotNull(sslConfiguration.getKeyStoreConfig());
diff --git a/log4j-jpa/src/test/java/org/apache/logging/log4j/core/appender/db/jpa/AbstractJpaAppenderTest.java b/log4j-jpa/src/test/java/org/apache/logging/log4j/core/appender/db/jpa/AbstractJpaAppenderTest.java
index 29ceb34ba1..dc963af2ab 100644
--- a/log4j-jpa/src/test/java/org/apache/logging/log4j/core/appender/db/jpa/AbstractJpaAppenderTest.java
+++ b/log4j-jpa/src/test/java/org/apache/logging/log4j/core/appender/db/jpa/AbstractJpaAppenderTest.java
@@ -36,7 +36,6 @@ import org.apache.logging.log4j.core.config.ConfigurationFactory;
 import org.apache.logging.log4j.core.config.DefaultConfiguration;
 import org.apache.logging.log4j.core.test.categories.Appenders;
 import org.apache.logging.log4j.status.StatusLogger;
-import org.apache.logging.log4j.util.PropertiesUtil;
 import org.junit.Test;
 import org.junit.experimental.categories.Category;
 
@@ -57,7 +56,6 @@ public abstract class AbstractJpaAppenderTest {
         System.setProperty(
                 ConfigurationFactory.CONFIGURATION_FILE_PROPERTY,
                 "org/apache/logging/log4j/core/appender/db/jpa/" + configFileName);
-        PropertiesUtil.getProperties().reload();
         final LoggerContext context = LoggerContext.getContext(false);
         if (context.getConfiguration() instanceof DefaultConfiguration) {
             context.reconfigure();
@@ -75,7 +73,6 @@ public abstract class AbstractJpaAppenderTest {
             ((JpaAppender) appender).getManager().close();
         } finally {
             System.clearProperty(ConfigurationFactory.CONFIGURATION_FILE_PROPERTY);
-            PropertiesUtil.getProperties().reload();
             context.reconfigure();
             StatusLogger.getLogger().reset();
 
diff --git a/src/changelog/.2.x.x/2849-remove-token-based-matching.xml b/src/changelog/.2.x.x/2849-remove-token-based-matching.xml
new file mode 100644
index 0000000000..32d8b3c24e
--- /dev/null
+++ b/src/changelog/.2.x.x/2849-remove-token-based-matching.xml
@@ -0,0 +1,8 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<entry xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+       xmlns="https://logging.apache.org/xml/ns"
+       xsi:schemaLocation="https://logging.apache.org/xml/ns https://logging.apache.org/xml/ns/log4j-changelog-0.xsd"
+       type="changed">
+  <issue id="2849" link="https://github.com/apache/logging-log4j2/pull/2849"/>
+  <description format="asciidoc">Remove configuration properties caching and (undocumented) fuzzy property name matching.</description>
+</entry>