Unable to serialise avro optional Decimal
See original GitHub issueDescribe the bug
Avro union types of Decimal do not serialise but throw
2021-10-18 17:51:46,311 ERROR [io.sma.rea.mes.kafka] (smallrye-kafka-producer-thread-0) SRMSG18212: Message org.eclipse.microprofile.reactive.messaging.Message$8@5702ccea was not sent to Kafka topic 'com.fnz.test.sink' - nacking message: org.apache.kafka.common.errors.SerializationException: Error serializing Avro message
Caused by: org.apache.avro.UnresolvedUnionException: Not in union ["null",{"type":"bytes","logicalType":"decimal","precision":13,"scale":6}]: 0.26268382480788643
at org.apache.avro.generic.GenericData.resolveUnion(GenericData.java:877)
at org.apache.avro.generic.GenericDatumWriter.resolveUnion(GenericDatumWriter.java:272)
at org.apache.avro.generic.GenericDatumWriter.writeWithoutConversion(GenericDatumWriter.java:143)
at org.apache.avro.specific.SpecificDatumWriter.writeField(SpecificDatumWriter.java:98)
at org.apache.avro.generic.GenericDatumWriter.writeRecord(GenericDatumWriter.java:210)
at org.apache.avro.specific.SpecificDatumWriter.writeRecord(SpecificDatumWriter.java:83)
at org.apache.avro.generic.GenericDatumWriter.writeWithoutConversion(GenericDatumWriter.java:131)
at org.apache.avro.generic.GenericDatumWriter.write(GenericDatumWriter.java:83)
at org.apache.avro.generic.GenericDatumWriter.write(GenericDatumWriter.java:73)
at io.confluent.kafka.serializers.AbstractKafkaAvroSerializer.serializeImpl(AbstractKafkaAvroSerializer.java:135)
at io.confluent.kafka.serializers.KafkaAvroSerializer.serialize(KafkaAvroSerializer.java:61)
at org.apache.kafka.common.serialization.Serializer.serialize(Serializer.java:62)
at org.apache.kafka.clients.producer.KafkaProducer.doSend(KafkaProducer.java:925)
at org.apache.kafka.clients.producer.KafkaProducer.send(KafkaProducer.java:885)
at io.smallrye.reactive.messaging.kafka.impl.ReactiveKafkaProducer.lambda$send$3(ReactiveKafkaProducer.java:102)
Serialisers all seem to work when I use them directly - either using Avro or using the KafkaAvroSerializer but when they are used within quarkus messages fail to serialise
Expected behavior
serialised and sent messages
Actual behavior
Exception and messages not sent
How to Reproduce?
Check out project:
https://github.com/msillence/quarkus-avro-decimal-bug
docker-compose up -d
in the project home
add mskafka and schema-registry to your hosts file pointing to your localhost
Run the quarkus application and you will see serialisation errors every second
Run the unit tests and they all pass
Output of uname -a or ver
Linux JHC8700TP 4.19.128-microsoft-standard #1 SMP Tue Jun 23 12:58:10 UTC 2020 x86_64 x86_64 x86_64 GNU/Linux
Output of java -version
openjdk version “17” 2021-09-14
GraalVM version (if different from Java)
No response
Quarkus version or git rev
2.3.0.Final
Build tool (ie. output of mvnw --version or gradlew --version)
apache-maven-3.8.1
Additional information
I have been trying to capture how the serialiser is constructed in the tests here:
specifically the first tests is meant to be similar to how the serialiser is constructed in quarkus but it all works under test so I feel this is difficult to pin on either avro or the confluent kafak serialiser
Issue Analytics
- State:
- Created 2 years ago
- Comments:10 (3 by maintainers)
Top Related StackOverflow Question
@msillence thanks a lot for getting to the bottom of it!
1.11.0 release would also fix it when they build a release.