This is an automated email from the ASF dual-hosted git repository.
mgrigorov pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/avro-rs.git
The following commit(s) were added to refs/heads/main by this push:
new 335e74e fix: Don't write avro.codec if codec is Null (#356)
335e74e is described below
commit 335e74edcfaf204e504d412bba0b52129603bc20
Author: Kriskras99 <[email protected]>
AuthorDate: Fri Dec 5 12:13:30 2025 +0100
fix: Don't write avro.codec if codec is Null (#356)
---
avro/src/writer.rs | 12 +++++++-----
avro/tests/schema.rs | 2 +-
2 files changed, 8 insertions(+), 6 deletions(-)
diff --git a/avro/src/writer.rs b/avro/src/writer.rs
index 31fb5c7..3b62b16 100644
--- a/avro/src/writer.rs
+++ b/avro/src/writer.rs
@@ -439,7 +439,9 @@ impl<'a, W: Write> Writer<'a, W> {
let mut metadata = HashMap::with_capacity(2);
metadata.insert("avro.schema", Value::Bytes(schema_bytes));
- metadata.insert("avro.codec", self.codec.into());
+ if self.codec != Codec::Null {
+ metadata.insert("avro.codec", self.codec.into());
+ }
match self.codec {
#[cfg(feature = "bzip")]
Codec::Bzip2(settings) => {
@@ -865,7 +867,7 @@ mod tests {
let mut writer = Writer::new(&schema, Vec::new())?;
writer.flush()?;
let result = writer.into_inner()?;
- assert_eq!(result.len(), 163);
+ assert_eq!(result.len(), 147);
// Unless the user indicates via the builder that the header has
already been written
let mut writer = Writer::builder()
@@ -1341,7 +1343,7 @@ mod tests {
writer.flush()?;
let result = writer.into_inner()?;
- assert_eq!(result.len(), 260);
+ assert_eq!(result.len(), 244);
Ok(())
}
@@ -1617,7 +1619,7 @@ mod tests {
let bytes = writer.append_ser(conf)?;
- assert_eq!(198, bytes);
+ assert_eq!(182, bytes);
Ok(())
}
@@ -1707,7 +1709,7 @@ mod tests {
assert_eq!(
shared_buffer.len(),
- 167,
+ 151,
"the test buffer was not fully written to after Writer::flush was
called"
);
diff --git a/avro/tests/schema.rs b/avro/tests/schema.rs
index 3c34230..be89102 100644
--- a/avro/tests/schema.rs
+++ b/avro/tests/schema.rs
@@ -816,7 +816,7 @@ fn test_record_schema_with_cyclic_references() ->
TestResult {
panic!("An error occurred while writing datum: {err:?}")
}
let bytes = writer.into_inner()?;
- assert_eq!(316, bytes.len());
+ assert_eq!(300, bytes.len());
match Reader::new(&mut bytes.as_slice()) {
Ok(mut reader) => match reader.next() {