Open vicenteg opened 6 years ago
And this is with which Jackson version?
2.9.2
<dependency>
<groupId>com.fasterxml.jackson.dataformat</groupId>
<artifactId>jackson-dataformat-avro</artifactId>
<version>2.9.2</version>
</dependency>
Ok. So reproduction is almost complete, one missing piece being the encoded input file. I think that is needed as presumably module would not write such content.
I am guessing this might be due to one unfortunate design by Avro authors, however... format is different when stored in a file compared to when encoded for transmission. If so, it will start with a marker and schema as json. Given lack of any metadata in encoding, this is not possible to reliably auto-detect; and it seems strange to require codecs to be aware of input source. At the moment this module does not have special handling for this prefix, although I think there is an issue for requesting implementation.
It should be relatively easy to check if input might be of this form: Avro specification outlines how the headers looks like:
https://avro.apache.org/docs/1.8.2/spec.html#Object+Container+Files
I think this is one of badly designed bad of specification and wonder what authors were smoking. But it is what it is.
For the encoded input file, you can use avrotools random to generate some data. I used a command line like the following:
avrotools random --schema-file test.avro.schema --count 100 test.avro
Here's a link to a sample file: https://storage.googleapis.com/vincegonzalez/jackson-dataformats-binary-issue-123.avro
Yes, that does start with Obj
signature indicating Object Container addition, with signature followed by JSON-encoded embedded schema.
So as things are, Object Container files are not supported, only raw encoded content. Issue #8 is about adding support for handling this case (both reading and writing).
Unsure if I'm doing something wrong here. I want to deserialize Avro to a Json string.
I've boiled my issue down to the following:
I get an exception:
The schema looks like this:
And I generated data from the schema using avrotools: