Fix gh-11899: Default addLocationInformation to false in Settings and Toolchains XML writers#11984
Open
abhu85 wants to merge 1 commit intoapache:masterfrom
Open
Fix gh-11899: Default addLocationInformation to false in Settings and Toolchains XML writers#11984abhu85 wants to merge 1 commit intoapache:masterfrom
abhu85 wants to merge 1 commit intoapache:masterfrom
Conversation
…gs and Toolchains XML writers DefaultSettingsXmlFactory.write() and DefaultToolchainsXmlFactory.write() always emitted InputLocation comments (e.g. <!-- /path/to/settings.xml:163 -->) because they created bare StaxWriter instances whose addLocationInformation field defaults to true, and never called setAddLocationInformation(false). Align both factories with DefaultModelXmlFactory.write(), which correctly defaults location tracking to false and only enables it when an explicit inputLocationFormatter is provided via XmlWriterRequest. Fixes apache#11899
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.
Summary
addLocationInformationtofalseinDefaultSettingsXmlFactory.write()andDefaultToolchainsXmlFactory.write()inputLocationFormatterfromXmlWriterRequest— only emit location comments when explicitly requestedDefaultModelXmlFactory.write(), which already handles this correctlyProblem
DefaultSettingsXmlFactory.write()always emitsInputLocationcomments (e.g.<!-- /path/to/settings.xml:163 -->) because it creates a barenew SettingsStaxWriter()whoseaddLocationInformationfield defaults totrue. It also ignores theinputLocationFormatterfrom theXmlWriterRequest.This is inconsistent with
DefaultModelXmlFactory.write(), which correctly defaults location tracking tofalseand only enables it when an explicitinputLocationFormatteris provided.The same issue exists in
DefaultToolchainsXmlFactory.write().Solution
Applied the same pattern from
DefaultModelXmlFactory.write()(lines 165-174) to both:addLocationInformation(false)by defaultrequest.getInputLocationFormatter()— if provided, enable location information and set the string formatterTest Plan
mvn -pl impl/maven-impl -am test— 461 tests pass, 0 failuresmvn spotless:apply— formatting appliedgit diff --check— no whitespace issuesCompatibility
inputLocationFormatternow get cleaner XMLinputLocationFormatterwill continue to get location commentsFixes #11899