[CSV-329] Fix byte tracking for supplementary delimiters#613
Merged
garydgregory merged 2 commits intoJun 19, 2026
Merged
Conversation
Member
|
Jira ticket is https://issues.apache.org/jira/browse/CSV-329 |
garydgregory
requested changes
Jun 18, 2026
garydgregory
left a comment
Member
There was a problem hiding this comment.
@OldTruckDriver
Thank you for the PR.
Please add a test to ExtendedBufferedReaderTest to help future maintenance.
TY!
ExtendedBufferedReader.read(char[], int, int) updated lastChar before computing the encoded byte length, so a surrogate pair in the delimiter lookahead buffer was paired against the post-update lastChar and threw CharacterCodingException. Count bytes before updating lastChar, and pair each char against the preceding char in the buffer seeded from lastChar so pairs split across reads still count. Add parser and ExtendedBufferedReader regression tests. Reviewed-by: OpenAI Codex Reviewed-by: Anthropic Claude Code
adf6397 to
1d89cd5
Compare
Contributor
Author
|
Added a direct ExtendedBufferedReaderTest unit test (testReadingSupplementaryCharacterTracksBytes) asserting the byte count for a supplementary character. Thanks! |
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.
[CSV-329] Fix byte tracking for supplementary delimiters
CSVParser with trackBytes enabled could throw CharacterCodingException when a multi-character delimiter contained a supplementary Unicode character. The failure happened while delimiter lookahead read a surrogate pair through ExtendedBufferedReader.read(char[]).
This change updates ExtendedBufferedReader byte-length accounting for char-buffer reads so surrogate pairs are evaluated with the correct previous character before lastChar is updated. This lets byte tracking remain metadata-only and not change parser correctness.
Tests cover trackBytes=true with a multi-character delimiter containing an emoji, including byte-position tracking across records.
Tests run: