[
https://issues.apache.org/jira/browse/AVRO-2912?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel
]
Nir Barel updated AVRO-2912:
----------------------------
Description:
Hi,
I tried to convert a protobuf bytes array into avro GenericRecord.
I used the avro-protobuf lib to generate the schema of my protobuf.
When I tries to convert my bytes array into GenericRecord I get an exception of
"org.apache.avro.AvroRuntimeException: Malformed data. Length is negative: -25"
Tried to debug this a bit, but couldn't tell why it fail on 1st field.
I double check my proto bytes array by converting it into protobuf object or
JSON and data is valid.
snip of my code:
{code:java}
Schema schema = ProtobufData.get().getSchema(Proto.class);
ProtobufDatumReader<Proto> datumReader = new
ProtobufDatumReader<>(Proto.class);
GenericDatumReader<GenericRecord> genericDatumReader = new
GenericDatumReader<>(datumReader.getSchema());
GenericRecord record = genericDatumReader.read(null,
DecoderFactory.get().binaryDecoder(new ByteArrayInputStream(bytes), null));
{code}
was:
Hi,
I tried to convert a protobuf bytes array into avro GenericRecord.
I used the avro-protobuf lib to generate the schema of my protobuf.
When I tries to convert my bytes array into GenericRecord I get an exception of
"org.apache.avro.AvroRuntimeException: Malformed data. Length is negative: -25"
Tried to debug this a bit, but couldn't tell why it fail on 1st field.
I double check my proto bytes array by converting it into protobuf object or
JSON and data is valid.
snip of my code:
{code:java}
Schema schema = ProtobufData.get().getSchema(Proto.class);
ProtobufDatumReader<Proto> datumReader = new
ProtobufDatumReader<>(Proto.class);
GenericDatumReader<GenericRecord> genericDatumReader = new
GenericDatumReader<>(datumReader.getSchema());
GenericRecord record = genericDatumReader.read(null,
DecoderFactory.get().binaryDecoder(new ByteArrayInputStream(bytes), null));
{code}
> Protobuf to Avro - throw an exception of
> "org.apache.avro.AvroRuntimeException: Malformed data. Length is negative:
> -25"
> ------------------------------------------------------------------------------------------------------------------------
>
> Key: AVRO-2912
> URL: https://issues.apache.org/jira/browse/AVRO-2912
> Project: Apache Avro
> Issue Type: Bug
> Components: java
> Affects Versions: 1.9.2
> Reporter: Nir Barel
> Priority: Major
>
> Hi,
> I tried to convert a protobuf bytes array into avro GenericRecord.
> I used the avro-protobuf lib to generate the schema of my protobuf.
> When I tries to convert my bytes array into GenericRecord I get an exception
> of "org.apache.avro.AvroRuntimeException: Malformed data. Length is negative:
> -25"
> Tried to debug this a bit, but couldn't tell why it fail on 1st field.
> I double check my proto bytes array by converting it into protobuf object or
> JSON and data is valid.
>
> snip of my code:
> {code:java}
> Schema schema = ProtobufData.get().getSchema(Proto.class);
> ProtobufDatumReader<Proto> datumReader = new
> ProtobufDatumReader<>(Proto.class);
> GenericDatumReader<GenericRecord> genericDatumReader = new
> GenericDatumReader<>(datumReader.getSchema());
> GenericRecord record = genericDatumReader.read(null,
> DecoderFactory.get().binaryDecoder(new ByteArrayInputStream(bytes), null));
> {code}
>
>
--
This message was sent by Atlassian Jira
(v8.3.4#803005)