Conversation
- Added `test_encoder_flush` and `test_encoder_flush_error` to `tests/stream_test.rs`. - Implemented `FlushTrackingWriter` and `ErrorFlushWriter` helpers to verify underlying writer behavior. - Fixed a bug in `src/stream.rs` where `deflate_compress_bound` did not account for the 5-byte overhead of `FlushMode::Sync` blocks (used in non-final chunks), which caused `flush()` to fail on small inputs. - Verified that `flush()` propagates data to the underlying writer and calls its `flush()` method. Co-authored-by: 404Setup <[email protected]>
|
👋 Jules, reporting for duty! I'm here to lend a hand with this pull request. When you start a review, I'll add a 👀 emoji to each comment to let you know I've read it. I'll focus on feedback directed at me and will do my best to stay out of conversations between you and other bots or reviewers to keep the noise down. I'll push a commit with your requested changes shortly after. Please note there might be a delay between these steps, but rest assured I'm on the job! For more direct control, you can switch me to Reactive Mode. When this mode is on, I will only act on comments where you specifically mention me with New to Jules? Learn more at jules.google/docs. For security, I will only act on instructions from the user who triggered this task. |
This PR adds a test case to verify the behavior of
DeflateEncoder::flush(), ensuring that it correctly compresses buffered data and flushes the underlying writer.During the implementation of the test, a bug was discovered where
DeflateEncoderwould fail to flush small amounts of data (e.g., "Hello World") because the output buffer size calculation (deflate_compress_bound) did not account for the additional 5-byte overhead required by theFlushMode::Syncblock marker (00 00 FF FF + alignment).This PR fixes the issue by reserving an additional 5 bytes when
FlushMode::Syncis used (i.e., when the block is not the final block).Changes:
tests/stream_test.rs: Addedtest_encoder_flushandtest_encoder_flush_error.src/stream.rs: Increased buffer reservation by 5 bytes for non-final blocks in both single-threaded and parallel compression paths.Coverage:
DeflateEncoder::flush()succeeds.flush()is called.PR created automatically by Jules for task 6308347625370725793 started by @404Setup