Skip to content

fix: reset cached batch in PageReadListener between sheets to avoid duplicate rows#961

Open
nkuprins wants to merge 1 commit into
apache:mainfrom
nkuprins:fix-pagereadlistener-multisheet-duplicates
Open

fix: reset cached batch in PageReadListener between sheets to avoid duplicate rows#961
nkuprins wants to merge 1 commit into
apache:mainfrom
nkuprins:fix-pagereadlistener-multisheet-duplicates

Conversation

@nkuprins

Copy link
Copy Markdown

Purpose of the pull request

Closed: #960

PageReadListener re-delivers the previous sheet's leftover rows when a single listener reads multiple sheets (doReadAll()) with a batch size greater than 1, so the consumer processes those rows twice.

What's changed?

doAfterAllAnalysed flushes the partially filled batch at the end of each sheet, but kept the delivered rows in cachedDataList. Since DefaultAnalysisEventProcessor.endSheet invokes doAfterAllAnalysed after every sheet and the same listener instance serves all sheets, the next sheet kept appending to the already-delivered list and re-emitted its rows as soon as the batch filled up.

The fix is a one-line reset of cachedDataList after the end-of-sheet flush, mirroring what invoke already does after delivering a full batch.

Regression test: SimpleDataTest.pageReadListenerMultipleSheets07 writes a two-sheet workbook (3 + 4 rows), reads all sheets with batch size 5, and asserts the exact delivered sequence. On current main it fails with sheet0's three rows delivered twice (10 deliveries instead of 7):

expected: <[FirstName0, FirstName1, FirstName2, SecondName0, SecondName1, SecondName2, SecondName3]>
 but was: <[FirstName0, FirstName1, FirstName2, FirstName0, FirstName1, FirstName2, SecondName0, SecondName1, SecondName2, SecondName3]>

Checklist

  • I have read the Contributor Guide.
  • I have written the necessary doc or comment.
  • I have added the necessary unit tests and all cases have passed.

@nkuprins nkuprins changed the title fix: reset cached batch in PageReadListener between sheets to avoid d… fix: reset cached batch in PageReadListener between sheets to avoid duplicate rows Jul 19, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Bug] PageReadListener re-delivers previous sheet's leftover rows when reading multiple sheets

1 participant