[
https://issues.apache.org/jira/browse/LOG4J2-3618?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=17617812#comment-17617812
]
Piotr Karwasz commented on LOG4J2-3618:
---------------------------------------
[~pwebb],
Thanks for debugging the issue.
The usage of an ordered set saves some {{sorted()}} calls, but the comparator
should distinguish between different property sources with the same priority,
which is clearly not the case right now.
That said I think that custom property sources should choose a different
priority from the standard ones. These are ordered from smallest scope (single
Spring Boot apps -100, single JVM Java properties 0) to largest scope
(environment variables for all JVMs in the system 100). Values over 100 are
used for developers default values.
> Multiple PropertySources with identical priority cannot be added to
> PropertiesUtil Environment
> ----------------------------------------------------------------------------------------------
>
> Key: LOG4J2-3618
> URL: https://issues.apache.org/jira/browse/LOG4J2-3618
> Project: Log4j 2
> Issue Type: Bug
> Components: Core
> Affects Versions: 2.17.2
> Reporter: Phillip Webb
> Priority: Minor
>
> The {{org.apache.logging.log4j.util.PropertiesUtil.Environment}} maintains a
> set of {{sources}} by using a {{ConcurrentSkipListSet}} backed with a
> {{PropertySource.Comparator}}.
> Somewhat surprisingly, the {{ConcurrentSkipListSet}} will not add an item if
> comparing it to an existing one returns {{0}}. This means that all
> {{PropertySource}} implementations must have unique {{getPriority()}}
> results. I think this might be better to use a {{Set}} that uses
> {{equals/hashCode}} to determine if items can be added and only use the
> {{Comparator}} for sorting.
--
This message was sent by Atlassian Jira
(v8.20.10#820010)