Skip to content

[To dev/1.1] Handle short reads from input streams - #1066

Merged
JackieTien97 merged 2 commits into
dev/1.1from
fix/read-fully-input-stream-dev-1.1
Nov 4, 2026
Merged

JackieTien97 merged 2 commits into
dev/1.1from
fix/read-fully-input-stream-dev-1.1

Conversation

@shuwenwei

Copy link
Copy Markdown
Member

Backport

Backport of #1061 to dev/1.1.

Problem

ReadWriteIOUtils assumed a single InputStream.read() call would fill the requested buffer. The InputStream contract permits partial reads, so valid data could fail with Intend to read N bytes but M are actually returned. The readAsPossible overloads also needed to distinguish zero-byte progress from EOF and avoid an extra hidden read.

Change

  • Read fixed-width values and length-prefixed strings until the requested bytes are available or EOF is reached.
  • Treat single-byte reader EOF as EOFException.
  • Retry zero-byte TsFileInput.read() and only treat negative values as EOF.
  • Remove the extra read in readAsPossible(TsFileInput, long, ByteBuffer).
  • Make BytesUtils.safeReadInputStreamToBytes fail on truncated input instead of returning zero-filled data.
  • Add focused fragmented-stream, truncation, EOF, and zero-read regression tests.

Compatibility

This backport keeps the dev/1.1 error-message and string-handling style and does not import develop-only i18n or unrelated refactors.

Validation

Per repository constraints, compilation and tests were not run locally. git diff --check passed.

@codecov-commenter

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 89.65517% with 6 lines in your changes missing coverage. Please review.
✅ Project coverage is 59.20%. Comparing base (396fdf2) to head (2cc87dc).

Files with missing lines Patch % Lines
...java/org/apache/tsfile/utils/ReadWriteIOUtils.java 89.58% 5 Missing ⚠️
.../main/java/org/apache/tsfile/utils/BytesUtils.java 90.00% 1 Missing ⚠️
Additional details and impacted files
@@             Coverage Diff             @@
##           dev/1.1    #1066      +/-   ##
===========================================
+ Coverage    59.09%   59.20%   +0.11%     
===========================================
  Files          420      420              
  Lines        28118    28158      +40     
  Branches      3716     3727      +11     
===========================================
+ Hits         16615    16672      +57     
+ Misses       11307    11290      -17     
  Partials       196      196              

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@JackieTien97
JackieTien97 merged commit 5bcb823 into dev/1.1 Nov 4, 2026
10 checks passed
@JackieTien97
JackieTien97 deleted the fix/read-fully-input-stream-dev-1.1 branch November 4, 2026 23:37
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.

3 participants