Joan Soto Targa created AVRO-3934: ------------------------------------- Summary: Generated Java code still fails with union containing logical type Key: AVRO-3934 URL: https://issues.apache.org/jira/browse/AVRO-3934 Project: Apache Avro Issue Type: Bug Components: java, logical types Affects Versions: 1.11.3, 1.9.2 Environment: apache maven, avro maven plugin, avro v1.11.3 or 1.9.2 (tried with both), code being generated in Java 8.
Faulty java generation happens in both maven running on intellij idea and on jenkins pipelines. Issue happens in both windows and linux. Reporter: Joan Soto Targa In our company we're using both 1.9.2 and 1.11.3 versions of avro compiling to Java 8 and in both cases we have observed that bug AVRO-1981 is still active and deserialization fails for nullable fields that have a logical type: happens at least for both "uuid" (in version 1.11.3, previous one just ignores this type) and "timestamp-millis" (in both versions). The error we get for the uuid case when attempting to deserialize is: {noformat} java.lang.ClassCastException: class org.apache.avro.util.Utf8 cannot be cast to class java.util.UUID {noformat} In the class code, we should be getting: {code:java} static { MODEL$.addLogicalTypeConversion(new Conversions.UUIDConversion()); MODEL$.addLogicalTypeConversion(new TimeConversions.TimestampMillisConversion()); ENCODER = new BinaryMessageEncoder(MODEL$, SCHEMA$); DECODER = new BinaryMessageDecoder(MODEL$, SCHEMA$); conversions = new org.apache.avro.Conversion<?>[] { null, null, new org.apache.avro.Conversions.UUIDConversion(), null, new org.apache.avro.data.TimeConversions.TimestampMillisConversion(), null }; WRITER$ = MODEL$.createDatumWriter(SCHEMA$); READER$ = MODEL$.createDatumReader(SCHEMA$); } {code} but we get: {code:java} static { MODEL$.addLogicalTypeConversion(new Conversions.UUIDConversion()); MODEL$.addLogicalTypeConversion(new TimeConversions.TimestampMillisConversion()); ENCODER = new BinaryMessageEncoder(MODEL$, SCHEMA$); DECODER = new BinaryMessageDecoder(MODEL$, SCHEMA$); WRITER$ = MODEL$.createDatumWriter(SCHEMA$); READER$ = MODEL$.createDatumReader(SCHEMA$); } {code} -- This message was sent by Atlassian Jira (v8.20.10#820010)