`Stax2ReaderAdapter.nextTag()` skips the adapter's own state handling

Aperta
#60 0 commenti 0 reazioni 0 assegnatari Vedi su GitHub

@winfriedgerlach ci sta già lavorando.

Dal 9/10/2026.

  • #61 di @winfriedgerlach — aperta

Valutazione

Difficoltà
3/5
Tempo stimato
Mezza giornata
Idoneità per principianti
70/100
Tipo di issue
Bug
Chiarezza
Specificata chiaramente
Stato di attività
Attiva
Stack tecnologico
java, xml
Ambito
api

Direzione di ricerca

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].

Scritto dal modello di indicizzazione a partire dal testo della issue.

Descrizione

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:

  1. Depth: getDepth() is not updated by nextTag(), so it is wrong for any code that walks elements with nextTag().
  2. 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.

Lingua principale
Java
Stelle
42
Fork
21
Merge medio
3h 50m
PR unite (30g)
2

Preparare l'ambiente

Questo progetto non fornisce container di sviluppo, Dockerfile né guida per i contributori, quindi l'ambiente è a tuo carico: parti dal suo README e consulta la nostra guida al primo contributo per i passaggi generali.

Come iniziare

  1. Leggi tutta la issue e poi la guida ai contributi del progetto.
  2. Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
  3. Fai un fork del repository e lavora su un branch.
  4. Apri una pull request che faccia riferimento al numero della issue.

Altre issue di FasterXML/stax2-api

Tutte le issue di FasterXML/stax2-api

Issue simili

Altre issue su Java

Ricevi le nuove issue nella tua casella

Un breve riepilogo di issue GitHub adatte ai principianti.