[ https://issues.apache.org/jira/browse/AVRO-3240?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]
Martin Tzvetanov Grigorov updated AVRO-3240: -------------------------------------------- Fix Version/s: 1.11.1 > Schema deserialization is not backwards compatible > -------------------------------------------------- > > Key: AVRO-3240 > URL: https://issues.apache.org/jira/browse/AVRO-3240 > Project: Apache Avro > Issue Type: Bug > Components: rust > Reporter: Ultrabug > Assignee: Martin Tzvetanov Grigorov > Priority: Critical > Labels: pull-request-available > Fix For: 1.11.1, 1.12.0 > > Time Spent: 4h > Remaining Estimate: 0h > > Hello, > > When providing your own schema to `from_avro_datum`, the deserialization is > not backward compatible with messages containing a previous schema even if > the schemas are created to be backward compatible. > This is due to the `decode_variable` function in `utils` returning > `Error::ReadVariableIntegerBytes` when the reader object is smaller than > expected when reading a message with previous schema version (which is indeed > smaller) and trying to decode it with a backward compatible schema. > I have fixed the issue locally with the following patch which I will submit > as a PR > > ``` > diff --git a/lang/rust/src/util.rs b/lang/rust/src/util.rs > index f9daf285..3538399e 100644 > --- a/lang/rust/src/util.rs > +++ b/lang/rust/src/util.rs > @@ -96,7 +96,7 @@ fn decode_variable<R: Read>(reader: &mut R) -> > AvroResult<u64> { > } > reader > .read_exact(&mut buf[..]) > - .map_err(Error::ReadVariableIntegerBytes)?; > + .or(Ok(()))?; // return nullable to support avro schemas backward > compatibility > i |= (u64::from(buf[0] & 0x7F)) << (j * 7); > if (buf[0] >> 7) == 0 { > break; > ``` -- This message was sent by Atlassian Jira (v8.20.1#820001)