-
Notifications
You must be signed in to change notification settings - Fork 2.8k
Fix MavenStaxReader location reporting for properties #11402
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
Merged
gnodet
merged 1 commit into
apache:master
from
gnodet:fix-stax-reader-location-reporting
Nov 6, 2025
Merged
Fix MavenStaxReader location reporting for properties #11402
gnodet
merged 1 commit into
apache:master
from
gnodet:fix-stax-reader-location-reporting
Nov 6, 2025
Conversation
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
f9e647b to
115b7c4
Compare
115b7c4 to
e6f99ee
Compare
The location for properties (Map elements) was being captured AFTER calling
nextText(), which moves the parser position past the element. This resulted
in incorrect location information.
This commit fixes the timing of location capture for properties by saving
the line and column numbers BEFORE calling nextText().
Changes:
- Modified src/mdo/reader-stax.vm to capture location before nextText() for properties
- Added comprehensive unit tests for location reporting:
* testLocationReportingForElements() - tests regular elements with exact line/column numbers
* testLocationReportingForAttributes() - tests XML attributes (root, child.scm.connection.inherit.append.path)
Note: Attributes get the location of their containing element since XMLStreamReader doesn't
provide individual attribute positions
* testLocationReportingForListElements() - tests list elements (modules) with exact line/column numbers
All tests pass successfully.
e6f99ee to
53575fa
Compare
cstamas
approved these changes
Nov 6, 2025
gnodet
added a commit
to gnodet/maven
that referenced
this pull request
Nov 6, 2025
The location for properties (Map elements) was being captured AFTER calling
nextText(), which moves the parser position past the element. This resulted
in incorrect location information.
This commit fixes the timing of location capture for properties by saving
the line and column numbers BEFORE calling nextText().
Changes:
- Modified src/mdo/reader-stax.vm to capture location before nextText() for properties
- Added comprehensive unit tests for location reporting:
* testLocationReportingForElements() - tests regular elements with exact line/column numbers
* testLocationReportingForAttributes() - tests XML attributes (root, child.scm.connection.inherit.append.path)
Note: Attributes get the location of their containing element since XMLStreamReader doesn't
provide individual attribute positions
* testLocationReportingForListElements() - tests list elements (modules) with exact line/column numbers
(cherry picked from commit 6f5c837)
# Conflicts:
# src/mdo/reader-stax.vm
Contributor
Author
💚 All backports created successfully
Questions ?Please refer to the Backport tool documentation |
gnodet
added a commit
that referenced
this pull request
Nov 6, 2025
The location for properties (Map elements) was being captured AFTER calling
nextText(), which moves the parser position past the element. This resulted
in incorrect location information.
This commit fixes the timing of location capture for properties by saving
the line and column numbers BEFORE calling nextText().
Changes:
- Modified src/mdo/reader-stax.vm to capture location before nextText() for properties
- Added comprehensive unit tests for location reporting:
* testLocationReportingForElements() - tests regular elements with exact line/column numbers
* testLocationReportingForAttributes() - tests XML attributes (root, child.scm.connection.inherit.append.path)
Note: Attributes get the location of their containing element since XMLStreamReader doesn't
provide individual attribute positions
* testLocationReportingForListElements() - tests list elements (modules) with exact line/column numbers
(cherry picked from commit 6f5c837)
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.
Problem
The location for properties (Map elements) in the MavenStaxReader was being captured after calling
nextText(), which moves the parser position past the element. This resulted in incorrect location information being reported.For example, when parsing:
The location for
maven.compiler.sourcewould point to the position after the closing tag instead of at the opening tag.Solution
This PR fixes the timing of location capture for properties by saving the line and column numbers before calling
nextText()that moves the parser position.Changes
Modified Files
src/mdo/reader-stax.vm
nextText()is calledimpl/maven-support/src/test/java/org/apache/maven/model/v4/MavenStaxReaderTest.java
testLocationReportingForElements()- tests regular elements with specific line and column number assertionstestLocationReportingForAttributes()- tests XML attributes (rooton project,child.scm.connection.inherit.append.pathon scm)testLocationReportingForListElements()- tests list elements (modules) with specific line and column number assertionsTesting
All tests pass successfully:
Benefits