flxo opened a new pull request, #438:
URL: https://github.com/apache/avro-rs/pull/438

   ### Problem
   
   `SpecificSingleObjectWriter` had a bug where it only wrote the single-object 
encoding header on the first call to `write_ref()`. Subsequent calls would 
write only the data without the header, making those messages unreadable.
   
   This violated the Avro single-object encoding specification, which requires
   that each message be independently decodable with its own header (2-byte 
marker + 8-byte schema fingerprint). This is critical for use cases like 
message queues where individual messages are stored or transmitted separately.
   
   ### Solution
   
   This PR removes the `header_written` flag from `SpecificSingleObjectWriter` 
and ensures that every call to `write_ref()` and `write()` writes a complete 
single-object encoded message (header + data). This matches the behavior of 
`GenericSingleObjectWriter` and conforms to the Avro specification.
   
   ### Changes
   
   - Removed the `header_written` field from `SpecificSingleObjectWriter`
   - Modified `write_ref()` to always write the header before writing data
   - Updated documentation to clarify that each call produces an independently 
decodable message
   - Added test verification that multiple writes to the same buffer each 
produce valid, independently decodable messages
   
   ### Test Plan
   
   The updated test in `avro/src/writer.rs:1573` verifies that:
   - Multiple calls to `write_ref()` produce identical output to calling 
`write_value()` multiple times
   - Each write produces a complete, independently decodable message
   - Output matches `GenericSingleObjectWriter` behavior
   
   Fixes #431 


-- 
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]

Reply via email to