Revamp XML configuration testing and documentation#4155
Open
ppkarwasz wants to merge 4 commits into
Open
Conversation
Rework the testing and documentation of the XML configuration format so that each behavior of the DOM-to-Node conversion is covered by its own focused test. `constructHierarchy`, `getType` and `processAttributes` are now static and take the `PluginManager` and `strict` flag as parameters, so the conversion can be unit-tested with a mocked `PluginManager` instead of a full `LoggerContext`. The `StrictXmlConfigTest` integration test is replaced by `XmlConfigurationConstructHierarchyTest`, which exercises plugin resolution, attribute folding, text values, strict-mode `type` resolution and XInclude whole-file/positional/by-id fragment resolution individually. The unused `Status`/`ErrorType` bookkeeping is dropped in favor of logging the error directly. The XML format documentation is moved into a reusable AsciiDoc partial and gains XPointer fragment examples. Testing each behavior individually surfaced a bug: the XInclude `fixup-language` feature adds an `xml:lang` attribute that was never stripped (only `xml:base` was) and was not covered by any test, so it leaked through as a Log4j configuration attribute. Matching the reserved XML namespace instead of the literal attribute name now strips both `xml:base` and `xml:lang`, and any other reserved `xml:` attribute. `XmlConfiguration` also stops explicitly enabling the XInclude `fixup-base-uris`/`fixup-language` features: they default to `true` and only add the attributes that Log4j strips. Assisted-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Verify that an included document may itself contain an `xi:include`, and that the inner relative `href` resolves against the included document's own location rather than the top-level configuration's. Assisted-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
This was referenced Jun 26, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
This PR reworks how the XML configuration format is tested and documented so that each behavior of the DOM-to-
Nodeconversion inXmlConfigurationis covered by its own focused test. Doing so surfaced a small attribute-handling bug, fixed here.Testing
constructHierarchy,getTypeandprocessAttributesare nowstaticand take thePluginManagerandstrictflag as parameters, so the DOM-to-Nodeconversion can be unit-tested with a mockedPluginManagerinstead of spinning up a fullLoggerContext.StrictXmlConfigTestintegration test (which only asserted event counts and merely happened to exercise strict-mode parsing) is replaced byXmlConfigurationConstructHierarchyTest, covering individually: plugin resolution, attribute folding, text-as-value, strict-modetyperesolution, and XInclude whole-file / positionalelement()/ by-name(ID) fragment resolution.Status/ErrorTypebookkeeping is dropped in favor of logging the error directly.Bug fix
fixup-languagefeature adds anxml:langattribute to included elements that was never stripped (onlyxml:basewas) and was not covered by any test, so it leaked through as a Log4j configuration attribute.processAttributesnow matches the reserved XML namespace instead of the literal attribute name, strippingxml:base,xml:lang, and any other reservedxml:attribute.XmlConfigurationno longer explicitly enables thefixup-base-uris/fixup-languagefeatures: they default totrueand onlyadd attributes Log4j strips (they are not required for nested or relative includes to resolve).
Documentation
configuration.adocis moved into a reusable AsciiDoc partial (partials/manual/configuration-xml-format.adoc).nameXPointer examples, plus a note that the JDK does not recognizexml:idand does not implement thexpointer()scheme.There is no behavior change for valid configurations; the only runtime difference is that
xml:langno longer leaks into the configuration.Checklist
2.x./mvnw verifysucceeds (only the affected modules were tested locally)src/changelog/.2.x.x