0z5a opened a new pull request, #8521: URL: https://github.com/apache/opendal/pull/8521
# Which issue does this PR close? Closes #8519. # Rationale for this change `BufferCursor::consume` only updated `pos`. It did not advance `view`, the slice that `fill_buf` and `read` serve from. After `fill_buf()` + `consume(n)`, the cursor handed out the same bytes again. As a result `lines()` repeated the first line forever, `read_line()` on input without a newline never reached EOF, and a `read()` after `consume()` returned bytes from the old position. # What changes are included in this PR? - `consume` now clamps the amount to the bytes left in `view`, advances `view`, and adds the same amount to `pos`, so the two stay in sync like they already do in `read`. - New unit test `test_buffer_cursor_bufread_consume` covers three cases on a two-chunk buffer: `fill_buf` after `consume`, `read` after `consume`, and `lines()`. It fails on main and passes with the change. # Are there any user-facing changes? Yes. Users who drive `BufferCursor` through `BufRead` (`lines`, `read_line`, `read_until`, or manual `fill_buf`/`consume`) now get each byte once, matching `std::io::Cursor`. The `Read` and `Seek` behavior is unchanged. # Breaking changes # AI Usage Statement - Harness: Claude Code - Model: claude-opus-5-5 (Claude Opus 5.5) - Effort: xhigh - Role: Found the bug while reading `BufferCursor`; wrote the reproduction, the fix and the regression test; drafted the issue and this description. Not checked: the whole workspace test suite with all features; only the `opendal-core` lib tests (242 passed), `cargo fmt --check` and `cargo clippy -p opendal-core --all-targets -- -D warnings` were run. -- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. To unsubscribe, e-mail: [email protected] For queries about this service, please contact Infrastructure at: [email protected]
