Repository navigation
GH-3869: Preserve destination state in single-buffer reads - #3870
Open
hutiefang76 wants to merge 1 commit into
Open
hutiefang76 wants to merge 1 commit into
hutiefang76 wants to merge 1 commit into
Conversation
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.
Rationale for this change
A
ByteBufferInputStreamselected from one source buffer flips the caller's destination, while the same public API with multiple source buffers advances its position and preserves its limit. This breaks prefilled destinations and subsequent append reads depending on the source layout.What changes are included in this PR?
Align the single-buffer read with the existing multi-buffer behavior: advance the destination by the copied count, preserve its limit, and leave it unchanged when there is no destination space or the stream is exhausted. Document the contract on the public method.
Are these changes tested?
The baseline has 12 single-buffer failures and 12 passing multi-buffer controls through both public
wrapoverloads. All 24 cases pass after the fix, covering partial/full copies, successive appends, heap/direct/sliced destinations, zero space and EOF.Root
./mvnw -B clean verifypassed on Microsoft OpenJDK 17.0.18 with Thrift 0.25.0: 2,914 tests, 0 failures/errors, 31 existing disabled or conditional skips (including optional Hadoop bridges and Windows-only checks). Spotless, Apache RAT and API compatibility checks stayed enabled.Are there any user-facing changes?
Single-buffer reads now leave the destination ready for further writes, matching multi-buffer streams. Callers can flip it once after filling it. EOF returns -1 when the destination has room; a destination with no remaining space returns 0. Public signatures are unchanged.
Closes #3869.