apache/avro-rs

Unstable test depending on serde's is_human_readable

Closed this issue · 1 comments

apache_avro::schema::tests::avro_rs_53_uuid_with_fixed fails sometimes with

  File "/home/martin/git/apache/avro-rs/avro/src/types.rs", line 462, in apache_avro::types::Value::validate_internal
  File "/home/martin/git/apache/avro-rs/avro/src/types.rs", line 606, in apache_avro::types::Value::validate_internal::{{closure}}
  File "/home/martin/.rustup/toolchains/stable-x86_64-unknown-linux-gnu/lib/rustlib/src/rust/library/core/src/slice/iter/macros.rs", line 232, in <core::slice::iter::Iter<T> as core::iter::traits::iterator::Iterator>::fold
  File "/home/martin/git/apache/avro-rs/avro/src/types.rs", line 593, in apache_avro::types::Value::validate_internal
  File "/home/martin/git/apache/avro-rs/avro/src/writer.rs", line 593, in apache_avro::writer::write_value_ref_owned_resolved
  File "/home/martin/git/apache/avro-rs/avro/src/writer.rs", line 497, in apache_avro::writer::GenericSingleObjectWriter::write_value_ref
  File "/home/martin/git/apache/avro-rs/avro/src/writer.rs", line 555, in apache_avro::writer::SpecificSingleObjectWriter<T>::write_ref
  File "/home/martin/git/apache/avro-rs/avro/src/schema.rs", line 6478, in apache_avro::schema::tests::avro_rs_53_uuid_with_fixed
  File "/home/martin/git/apache/avro-rs/avro/src/schema.rs", line 6447, in apache_avro::schema::tests::avro_rs_53_uuid_with_fixed::{{closure}}

Serde calls

avro-rs/avro/src/ser.rs

Lines 180 to 185 in d6a1e4f

fn serialize_bytes(self, v: &[u8]) -> Result<Self::Ok, Self::Error> {
match SER_BYTES_TYPE.get() {
BytesType::Bytes => Ok(Value::Bytes(v.to_owned())),
BytesType::Fixed => Ok(Value::Fixed(v.len(), v.to_owned())),
}
}
instead of

avro-rs/avro/src/ser.rs

Lines 176 to 178 in d6a1e4f

fn serialize_str(self, v: &str) -> Result<Self::Ok, Self::Error> {
Ok(Value::String(v.to_owned()))
}
when serializing Comment::id field of type Uuid.

It appears the reason is serializer.is_human_readable():

https://github.com/uuid-rs/uuid/blob/4473398413f7e3f4103374559b8d038b4801329a/src/external/serde_support.rs#L23-L31

Fixed with #72