Skip to content

Core: Align ByteBufferInputStream read behavior - #17423

Open
fallintoplace wants to merge 1 commit into
apache:mainfrom
fallintoplace:fix/byte-buffer-input-stream-read
Open

Core: Align ByteBufferInputStream read behavior#17423
fallintoplace wants to merge 1 commit into
apache:mainfrom
fallintoplace:fix/byte-buffer-input-stream-read

Conversation

@fallintoplace

Copy link
Copy Markdown

What changes are included?

  • Keep destination ByteBuffers in write mode after SingleBufferInputStream.read(ByteBuffer).
  • Return -1 at EOF while preserving 0 for destinations without remaining space.
  • Add shared coverage that verifies the same behavior for single-buffer and multi-buffer streams.

Why is this change necessary?

ByteBufferInputStream.wrap selects its implementation based on the number of source buffers. The single-buffer implementation flipped the destination after writing, while the multi-buffer implementation advanced its position normally. As a result, the destination state and EOF result depended on how the source was internally split.

Testing

  • ./gradlew :iceberg-core:test --tests org.apache.iceberg.io.TestSingleBufferInputStream --tests org.apache.iceberg.io.TestMultiBufferInputStream
  • ./gradlew :iceberg-core:spotlessCheck :iceberg-core:checkstyleMain :iceberg-core:checkstyleTest

AI Disclosure

  • Model: OpenAI language model
  • Platform/Tool: OpenAI desktop app
  • Human Oversight: fully reviewed
  • Prompt Summary: Investigated inconsistent ByteBufferInputStream behavior, implemented a focused fix, and added regression coverage.

Keep the destination buffer in write mode after reads and return the standard EOF result consistently across backing implementations.

Generated-by: OpenAI
@github-actions github-actions Bot added the core label Jul 29, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants