[Avro] Incompatibility with Avro >=1.9.0
See original GitHub issueAvro version 1.9.0 was released last month (https://mvnrepository.com/artifact/org.apache.avro/avro) and my team has run in to compatibility issues between jackson-dataformat-avro
and this latest release.
In particular, it looks to be the case that Avro has switched from Codehaus Jackson to FasterXML Jackson, which results in NoSuchMethodError
thrown when accessing utility methods.
The following test exposes the issue:
@Test
public void beanShouldBeSerializableAsAvroBinaryAndDeserializable() throws Exception {
TestBean testBean = new TestBean();
testBean.setData("Data");
AvroMapper avroMapper = new AvroMapper();
AvroSchema avroSchema = avroMapper.schemaFor(TestBean.class);
ByteArrayOutputStream outputStream = new ByteArrayOutputStream();
avroMapper.writer().with(avroSchema).writeValue(outputStream, testBean);
byte[] serialized = outputStream.toByteArray();
assertNotNull(serialized);
assertTrue(serialized.length > 0);
TestBean deserialized = avroMapper.readerFor(TestBean.class).with(avroSchema).readValue(serialized);
assertEquals(testBean, deserialized);
}
public static final class TestBean {
private String data;
@Override
public boolean equals(Object o) {
if (this == o)
return true;
if (o == null || getClass() != o.getClass())
return false;
TestBean testBean = (TestBean) o;
return Objects.equals(data, testBean.data);
}
@Override
public int hashCode() {
return Objects.hash(data);
}
public String getData() {
return data;
}
public void setData(String data) {
this.data = data;
}
}
This test passes on v1.8.2 of Avro, but fails with v1.9.0 on the following:
java.lang.NoSuchMethodError: org.apache.avro.util.internal.JacksonUtils.toObject(Lorg/codehaus/jackson/JsonNode;)Ljava/lang/Object;
at com.fasterxml.jackson.dataformat.avro.schema.RecordVisitor.schemaFieldForWriter(RecordVisitor.java:192)
at com.fasterxml.jackson.dataformat.avro.schema.RecordVisitor.optionalProperty(RecordVisitor.java:121)
at com.fasterxml.jackson.databind.ser.BeanPropertyWriter.depositSchemaProperty(BeanPropertyWriter.java:839)
at com.fasterxml.jackson.databind.ser.std.BeanSerializerBase.acceptJsonFormatVisitor(BeanSerializerBase.java:861)
at com.fasterxml.jackson.databind.ser.DefaultSerializerProvider.acceptJsonFormatVisitor(DefaultSerializerProvider.java:566)
at com.fasterxml.jackson.databind.ObjectMapper.acceptJsonFormatVisitor(ObjectMapper.java:3874)
at com.fasterxml.jackson.databind.ObjectMapper.acceptJsonFormatVisitor(ObjectMapper.java:3853)
at com.fasterxml.jackson.dataformat.avro.AvroMapper.schemaFor(AvroMapper.java:96)
Note that we are using com.fasterxml.jackson.dataformat:jackson-dataformat-avro:2.9.9
Issue Analytics
- State:
- Created 4 years ago
- Comments:35 (19 by maintainers)
Top Results From Across the Web
Highlights from the new Apache Avro 1.9.0 release
Apache Avro is compiled and tested with Java 11 to guarantee compatibility. Java8 is offically supported until March 2022, but it is good ......
Read more >Apache Avro™ 1.9.0 Specification
Apache Avro™ 1.9.0 Specification ... Since the compatibility of two schemas depends on both the data and the serialization format (eg.
Read more >Re: Problems with Avro upgrade from 1.9 to 1.10
I would be surprised that it would break compatibility just because it writes the schema definition in a different order.
Read more >Safety Considerations When Using Enums in Avro Schemas
Avro is much loved because of its schema compatibility features. ... Using Avro 1.9.0+ and adding default symbols fixes the problems associated with ......
Read more >org.apache.avro : avro : 1.9.0 - Maven Central
<?xml version="1.0" encoding="UTF-8"?> <!-- Licensed to the Apache Software Foundation (ASF) under one or more contributor license agreements.
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
FWIW, @baharclerode the issue you brought up about nested class name deserialization breaking with Avro [1.9.0, 1.10.0) may have been fixed in ~1.10.0~ (actually, looks like it may not have gotten in to 1.10.0) by this PR
Could you check if this is still the case with Apache Avro 1.9.2? Would love to help here.