[ 
https://issues.apache.org/jira/browse/LOG4J2-3618?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=17618967#comment-17618967
 ] 

Ralph Goers commented on LOG4J2-3618:
-------------------------------------

[~pkarwasz] What you are suggesting sounds different than the problem being 
reported. We clearly should allow multiple PropertySources with the same 
priority. However, it sounds like disallowing that was an attempt to prevent 
Log4j PropertySources from being modified or replaced. We could handle that 
just by disallowing PropertySources to be added or removed that are within a 
specified range. But that would also prevent users from inserting 
PropertySources into the middle of the list.

I added the addPropertySource method recently to better support the case where 
Spring cannot add its PropertySource until after Log4j has created the initial 
set of PropertySources. From Phil's description it sounds like we also need to 
allow for removal/replacement for testing. 



> 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)

Reply via email to