Repository navigation
Fix InputStreamReader short reads and EUC-KR chunk boundaries - #213
Conversation
Codex Review SummaryThis comment shows the latest Codex review activity on this pull request.
ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings. |
Codecov Report✅ All modified and coverable lines are covered by tests. 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. 🚀 New features to boost your workflow:
|
There was a problem hiding this comment.
💡 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".
There was a problem hiding this comment.
🔵 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
readinto a single loop that copies decoded characters into the caller's buffer, shifts/retains leftoverwriteBufchars, and stops early viaInputStream.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..=0xfelead 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.
Symptoms
InputStreamReader.readreturns 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