-
Notifications
You must be signed in to change notification settings - Fork 1.6k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
DefaultMergeStrategy - problem merging filters #3173
Comments
@ppkarwasz - Hi Piotr, can you maybe take a quick look at the The problem I think that exists is that the
If you agree that this might be problematic I can create a separate bug for that... but since |
Thank you for stress-testing the
It appears so. In general the class lacks some helper methods that would make the code easier to read, like
Filter composition is probably something that should be discussed separately, you can post a thread on the Some initial thoughts:
Scripts without a name in the global |
Thanks @ppkarwasz, Unfortunately I feel I lack the deeper understanding of the filter logic to lead such a discussion. :) I am decent at finding "holes" in a code-review but the implications and caveats of filter compisition are not all known to me. My concern about Scripts with no name is probably moot. All scripts with a null-name (missing a |
One other thing I noticed in my testing, the DefaultMergeStrategy uses the root node of the first configuration to merge all the others - this results in the first configuration being modified (regardless of type). For example, if the first is a XmlConffiguration and a second XmlConfiguration is merged - the internal node structure of the first is modified. I was wondering why, when a "reconfigure" is started on a CompositeConfiguration, isn't a new empty root-node used as the target for the merges? |
That it probably a mistake, the target should be the root node of the |
I had to work around it myself by creating a custom AbstractConfiguration implementation with the prepared empty child nodes for Loggers, Appenders, etc. and ensure that is always first in my CompositeConfigurations. Like the BuiltConfiguration it breaks down if you don't do a minimum prepopulation of child nodes / components - i.e. BuiltConfiguration NPEs if you don't prepopulate the root component with all child components. |
DefaultMergeStrategy (Log4j 2.24.1)
In
DefaultMergeStrategy#updateFilterNode
I think there is a problem when merging two configurations with filters and the target does not yet contain aCompositeFilter
. (in the code below this is theelse
case).If I am not mistaken, there is a step missing to add the children of the 'sourceChildNode' to the new
node
.I think it should be (see line commented with "
<==== ADDED
").For example if merging a secondary configuration (source) containing the following filter to a base configuration (target) when the target contains a filter (but not a
CompositeFilter
):I believe all the
KeyValuePair
children would be dropped during merge with the current code.In addition, the current code does not account for the possibilty of the
sourceChildNode
being aCompositeFilter
which would result in nested composite-filters. (this applies to both theif
andelse
branches of the original code.Would result in:
But should probably be:
The text was updated successfully, but these errors were encountered: