jackson-dataformats-binary: Avro 1.12.0 breaks jackson-dataformat-avro (also: requires JDK 11)
We were attempting to upgrade our project to Avro 1.12.0 with jackson-dataformat-avro version 2.17.2
The failure I get is as follows:
Exception in thread "main" java.lang.NoSuchMethodError: 'org.apache.avro.Schema$Parser org.apache.avro.Schema$Parser.setValidate(boolean)'
at com.fasterxml.jackson.dataformat.avro.AvroMapper.schemaFrom(AvroMapper.java:240)
at com.fmr.difrango.ztester.DemoJacksonAvroFailure.main(DemoJacksonAvroFailure.java:23)
To demonstrate this, I created the following example program that uses issue19.avsc as the schema to load.
package com.difrango.ztester;
import com.fasterxml.jackson.dataformat.avro.AvroMapper;
import com.fasterxml.jackson.datatype.jdk8.Jdk8Module;
import com.fasterxml.jackson.datatype.jsr310.JavaTimeModule;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import java.io.IOException;
public class DemoJacksonAvroFailure {
private static final Logger LOGGER = LoggerFactory.getLogger(DemoJacksonAvroFailure.class);
public static void main(String[] args) {
var expectedStream =
DemoJacksonAvroFailure.class.getClassLoader().getResourceAsStream("issue19.avsc");
var mapper = new AvroMapper();
mapper.registerModule(new Jdk8Module());
mapper.registerModule(new JavaTimeModule());
try {
var expected = mapper.schemaFrom(expectedStream);
} catch (IOException e) {
LOGGER.error("Error Handling the Schema", e);
}
}
}
About this issue
- Original URL
- State: open
- Created 2 years ago
- Reactions: 1
- Comments: 32 (16 by maintainers)
I’ll try to take this on but it won’t be until mid-January.
Thank you @rdifrango !
https://issues.apache.org/jira/browse/AVRO-4110
Well, for the double case, I at least tracked it down to here and it’s close to what you thought, they’re converting the Double to a floatValue and when it’s called it returns either
0orInfinitywhich feels like a bug in Avro to me:https://github.com/apache/avro/blob/main/lang/java/avro/src/main/java/org/apache/avro/generic/PrimitivesArrays.java#L549-L554
Sounds like some level of casting would be needed, somewhere. But not quite sure how/why breakage; I guess Avro Codec started using more accurate Java types, maybe, for its binding (or more generic?).
I know above is not super helpful, just thinking out aloud I guess.
To your point, with
Apache to Apache with Jackson schemaorJackson to Apache with Jackson schemathe following do work fine:The one that fails with different values is:
The ones not working at all are:
Shorts
java.lang.ClassCastException: class java.lang.Short cannot be cast to class java.lang.Integer (java.lang.Short and java.lang.Integer are in module java.base of loader 'bootstrap')Characters
java.lang.ClassCastException: class java.lang.Character cannot be cast to class java.lang.Integer (java.lang.Character and java.lang.Integer are in module java.base of loader 'bootstrap')Bytes -
java.lang.ClassCastException: class java.lang.Byte cannot be cast to class java.lang.Integer (java.lang.Byte and java.lang.Integer are in module java.base of loader 'bootstrap')ok, I started looking at this and it seems to break a few of the tests. The two groups in particular
Jackson to Apache with Jackson schemaandApache to Apache with Jackson schema.In the one test
ListWithPrimitiveWrapperTest.testListWithShortsit’s complaining aboutjava.lang.ClassCastException: class java.lang.Short cannot be cast to class java.lang.Integer (java.lang.Short and java.lang.Integer are in module java.base of loader 'bootstrap')I’m just trying to understand these tests before moving forward.
Ok, so Avro lib backwards-compatibility is really… not. There isn’t any. 1.11.3 -> 1.11.4 breaks tests, as per #539. Patches can be as breaking as minor version or so.
One other reason why we probably cannot upgrade: looks like Avro 1.12.0 is built with JDK 11, and Jackson 2.18 still has Java 8 as the baseline.
agreed the damage is done, the commons-validator was more an indicator that other apache projects seem to hold to strict guidelines around binary and API compatibility which clearly Avro has not.
Thanks @cowtowncoder. It’s interesting that we’ve been successfully using AVRO 1.11.2 so it must be some edge cases that we aren’t currently hitting.