JWT007 commented on issue #3173:
URL: 
https://github.com/apache/logging-log4j2/issues/3173#issuecomment-2456641919

   @ppkarwasz - Hi Piotr, can you maybe take a quick look at the 
`mergeConfigurations` implementation and see if you also maybe see a similar 
problem as described in this issue with merging Scripts?
   
   The problem I *think* that exists is that the `name` attribute on a 
`Script/ScriptRef/ScriptFile` is _optional_.  So if for whatever reason, 
multiple scripts with no name exist, they will continue to overwrite each other 
during merge so that only the last unnamed script is retained.
   
   ```
   switch (toRootLowerCase(targetChildNode.getName())) {
       case PROPERTIES:
       case SCRIPTS:
       case APPENDERS: {
           for (final Node node : sourceChildNode.getChildren()) {
               for (final Node targetNode : targetChildNode.getChildren()) {
                   if (Objects.equals(  // <=== two unnamed scripts (NAME == 
null) would match and remove the existing
                           targetNode.getAttributes().get(NAME),
                           node.getAttributes().get(NAME))) {
                       targetChildNode.getChildren().remove(targetNode);
                       break;
                   }
               }
               targetChildNode.getChildren().add(node);
           }
           isMerged = true;
           break;
       }
   ```
   
   If you agree that this *might* be problematic I can create a separate bug 
for that... but since `name` is optional I am not sure how the merge strategy 
should work - or how those scripts are even referenced? (why is name optional? 
:) )


-- 
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-unsubscr...@logging.apache.org

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

Reply via email to