`Stax2ReaderAdapter.nextTag()` skips the adapter's own state handling
Assessment
- Difficulty
- 3/5
- Estimated time
- Half a day
- Newbie friendliness
- 70/100
Research direction
Start with Stax2ReaderAdapter, which inherits nextTag() from StreamReaderDelegate and so bypasses the adapter's own next(), where depth and pending chunked-read handling live. Compare the two methods, then run Stax2ReaderAdapterTest and ReadElementAsArrayTest. Done when getDepth() matches between next() and nextTag(), and the repro reads [6, 7, 8] for <b> instead of [3, 4, 5].
Written by the indexing model from the issue text.
Description
Found this bug along the way. Please have look. I'll provide PR with tests.
Stax2ReaderAdapter does not override nextTag(), so the nextTag() it inherits from StreamReaderDelegate calls the wrapped reader's nextTag() directly and bypasses the adapter's next(). Two effects:
- Depth:
getDepth()is not updated bynextTag(), so it is wrong for any code that walks elements withnextTag(). - Chunked array reads: if an element was only partly read with
readElementAsIntArray()etc.,nextTag()doesn't discard the unread rest. Array reads of the next element then return the previous element's leftovers.
Repro: <root><a>1 2 3 4 5</a> <b>6 7 8</b></root>. Read 2 values of <a>, then nextTag() twice to reach <b>, then read <b> as an int array → [3, 4, 5] (expected: [6, 7, 8]).
Fix: override nextTag() like next(): end a pending chunked read by returning END_ELEMENT, and otherwise update the depth for the start or end element returned. Tests: Stax2ReaderAdapterTest (depths with next() vs nextTag(), and after leaving a chunked read early) and ReadElementAsArrayTest.leavesNothingForNextElementWhenAbandonedViaNextTag.
- Dominant language
- Java
- Stars
- 42
- Forks
- 21
- Avg merge
- 3h 50m
- Merged PRs (30d)
- 2
Getting set up
This project ships no dev container, Dockerfile or contributing guide, so setting up is up to you: start from its README, and see our first-contribution guide for the general steps.
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
More from FasterXML/stax2-api
-
Difficulty 4/5 3-5 days Newbie friendliness 45/100
-
`DOMWrappingReader.getDepth()` is one too low at `START_ELEMENT`, and typed array reads lose a levelOpen
Difficulty 3/5 1-2 days Newbie friendliness 58/100
-
Difficulty 2/5 1-3 hours Newbie friendliness 35/100
All issues in FasterXML/stax2-api
Similar issues
-
Cleanup: restore the interrupt flag in AiFailureAnalyzerPossibly taken @Rishankgupta08 claimed this today. Opengood first issue
Difficulty 2/5 1-3 hours Newbie friendliness 82/100
seleniumboot/selenium-boot#258 · 1 comment ·
Maintainers usually reply within 1 day
-
Difficulty 1/5 Under an hour Newbie friendliness 88/100
johanhaleby/occurrent#1505 ·
Maintainers usually reply within 1 day
-
bug
Difficulty 2/5 1-3 hours Newbie friendliness 72/100
Maintainers usually reply within 1 day
-
Difficulty 2/5 1-3 hours Newbie friendliness 72/100
FasterXML/jackson-databind#6443 ·
Maintainers usually reply within 1 day
-
Docs: 2 broken linksOpen
Difficulty 1/5 Under an hour Newbie friendliness 78/100
Maintainers usually reply within 1 day