Skip to content

Fix InputStreamReader short reads and EUC-KR chunk boundaries - #213

Merged
dlunch merged 1 commit into
mainfrom
fix/input-stream-reader-short-read
Oct 14, 2026
Merged

dlunch merged 1 commit into
mainfrom
fix/input-stream-reader-short-read

Conversation

@dlunch

@dlunch dlunch commented Oct 14, 2026

Copy link
Copy Markdown
Owner

Symptoms

InputStreamReader.read returns after the first byte chunk even when more input is immediately available. EUC-KR characters can also be lost when a complete byte pair ends at a chunk boundary.

Changes

  • Drain decoded chunks into the destination and continue while input is available, retaining partial reads when further input would require waiting.
  • Preserve complete EUC-KR byte pairs, incomplete multibyte sequences, buffered characters, and EOF handling.
  • Extend regression coverage for multi-chunk reads, destination offsets, partial reads, and UTF-8/EUC-KR boundaries.

Copilot AI balanced review requested due to automatic review settings October 14, 2026 03:38
@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Oct 14, 2026 •

Copy link
Copy Markdown

Codex Review Summary

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review ✅ Completed 2026-10-14T03:41:12.906400Z 9a3ee72 PR opened
ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

@codecov

codecov Bot commented Oct 14, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 87.19%. Comparing base (67eb81b) to head (9a3ee72).
⚠️ Report is 3 commits behind head on main.

Additional details and impacted files
@@            Coverage Diff             @@
##             main     #213      +/-   ##
==========================================
+ Coverage   87.18%   87.19%   +0.01%     
==========================================
  Files         308      308              
  Lines       46371    46374       +3     
==========================================
+ Hits        40427    40437      +10     
+ Misses       5944     5937       -7     

☔ 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.

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 9a3ee728f0

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread rustjava-runtime/src/classes/java/io/input_stream_reader.rs
@dlunch
dlunch merged commit 48a997a into main Oct 14, 2026
16 checks passed
@dlunch
dlunch deleted the fix/input-stream-reader-short-read branch October 14, 2026 03:41

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🔵 Needs a closer look

It is a subtle rewrite of core streaming character-decode control flow (chunk-boundary multibyte handling, cross-call buffering, and available()-driven short reads) whose many edge cases warrant final human verification.

0 open findings

What changed in this PR

This PR reworks java.io.InputStreamReader.read([CII) so it keeps decoding and draining input while bytes are immediately available, instead of returning after the first decoded byte chunk. It also replaces the previous naive EUC-KR "last byte looks like a lead byte" heuristic with a forward pair-walk that only truncates a genuinely incomplete trailing lead byte, fixing character loss when a complete EUC-KR pair lands on a BUF_SIZE chunk boundary. This addresses correctness/latency behavior of a core runtime I/O class used throughout the standard library.

Changes:

  • Restructured read into a single loop that copies decoded characters into the caller's buffer, shifts/retains leftover writeBuf chars, and stops early via InputStream.available() once at least one character has been produced (avoiding blocking for more input).
  • Replaced the EUC-KR boundary check with a pair-aligned scan (0x81..=0xfe lead bytes) that preserves complete pairs and only defers an incomplete trailing lead byte; UTF-8 handling is unchanged.
  • Expanded regression tests for multi-chunk draining, destination offsets, partial/one-byte-at-a-time reads, and UTF-8/EUC-KR chunk boundaries (including replacement-char-at-EOF behavior).
File Description
rustjava-runtime/​src/​classes/​java/​io/​input_stream_reader.rs Rewrites read to drain available input into a persistent writeBuf, and fixes EUC-KR chunk-boundary pair detection.
rustjava-runtime/​tests/​classes/​java/​io/​test_input_stream_reader.rs Adds/updates tests covering multi-chunk draining, offsets, partial reads, and UTF-8/EUC-KR split-multibyte boundaries.

🧠 Review effort: Balanced


💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

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.

2 participants