Repository navigation
fix: fill FileIO chunks after short positive reads - #3815
Merged
Merged
Conversation
He-Pin
force-pushed
the
fix/file-source-handle-short-reads
branch
from
November 26, 2026 13:01
114746e to
38f4839
Compare
Motivation: A positional file-channel read can return fewer bytes than requested without reaching EOF. Treating that as EOF could truncate the source. Modification: Keep filling the existing buffer after positive progress. Emit a full chunk, or the remaining bytes on a terminal read, without changing the read-ahead limit or materialized result and close ordering. Result: Short positive reads yield full chunks until the final chunk. The existing zero-read termination policy is unchanged. Tests: - Native FileSourceSpec and FileSourceCloseFailureSpec: 20/20 each on Scala 2.13.18 and 3.3.9, JDK 17. - The exact pre-fix FileSource blob failed the new case, as expected, with the same Scala 2.13 test classes. - Scoped Scalafmt, license header checks and git diff --check passed. References: Refs apache#3808 and apache#3815.
He-Pin
force-pushed
the
fix/file-source-handle-short-reads
branch
from
November 27, 2026 09:50
38f4839 to
ce2ac37
Compare
He-Pin
marked this pull request as ready for review
November 27, 2026 19:47
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.
Motivation
A positional file-channel read can return fewer bytes than requested without reaching EOF. Treating a short positive read as EOF can truncate the source.
Modification
Keep filling the existing buffer while reads make progress. Emit full chunks and a final partial chunk when needed, while retaining the existing read-ahead limit and zero-read termination policy. Exercise a channel that returns two bytes per read from a nonzero offset and document the chunk-size contract.
Result
FileIO.fromPathreads through short positive reads without changing its public API or the close-before-result ordering. The branch now contains only the short-read change atop Apachemain, after #3808 merged.Tests
References
Refs #3808.