You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@logging.apache.org by GitBox <gi...@apache.org> on 2022/02/26 06:27:39 UTC

[GitHub] [logging-log4j2] ppkarwasz commented on a change in pull request #774: [LOG4J2-3413] Fixes resolution of non-Log4j properties

ppkarwasz commented on a change in pull request #774:
URL: https://github.com/apache/logging-log4j2/pull/774#discussion_r815276131



##########
File path: log4j-api/src/main/java/org/apache/logging/log4j/util/PropertySource.java
##########
@@ -100,9 +101,19 @@ public int compare(final PropertySource o1, final PropertySource o2) {
      * @since 2.10.0
      */
     final class Util {
-        private static final String PREFIXES = "(?i:^log4j2?[-._/]?|^org\\.apache\\.logging\\.log4j\\.)?";
-        private static final Pattern PROPERTY_TOKENIZER = Pattern.compile(PREFIXES + "([A-Z]*[a-z0-9]+|[A-Z0-9]+)[-._/]?");
+        private static final Pattern PREFIX_PATTERN = Pattern.compile(
+                // just lookahead for AsyncLogger
+                "(^log4j2?[-._/]?|^org\\.apache\\.logging\\.log4j\\.)|(?=AsyncLogger(Config)?\\.)",
+                Pattern.CASE_INSENSITIVE);
+        private static final Pattern PROPERTY_TOKENIZER = Pattern.compile("([A-Z]*[a-z0-9]+|[A-Z0-9]+)[-._/]?");
         private static final Map<CharSequence, List<CharSequence>> CACHE = new ConcurrentHashMap<>();
+        static {
+            // Add legacy properties without Log4j prefix
+            CACHE.put("disableThreadContext", Arrays.asList("disable", "thread", "context"));
+            CACHE.put("disableThreadContextStack", Arrays.asList("disable", "thread", "context", "stack"));
+            CACHE.put("disableThreadContextMap", Arrays.asList("disable", "thread", "context", "map"));
+            CACHE.put("isThreadContextMapInheritable", Arrays.asList("is", "thread", "context", "map", "inheritable"));
+        }

Review comment:
       These are here just to satisfy `LegacyPropertiesCompatibilityTest`, which verifies that the tokenized version of the legacy and normalized properties are the same.
   
   From the `PropertiesUtil` perspective they are not strictly necessary, since `getStringProperty("disableThreadContext")` will always look up at least the exact string "disableThreadContext" and it will retrieve the value before falling back to token-based comparison.




-- 
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: notifications-unsubscribe@logging.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org