[ 
https://issues.apache.org/jira/browse/AVRO-3934?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel
 ]

Joan Soto Targa updated AVRO-3934:
----------------------------------
    Description: 
In our company we're using both 1.9.2 and 1.11.3 versions of avro compiling to 
Java 8 (or 11) 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 generated class file we should be getting:
{code:java}
private static final org.apache.avro.Conversion<?>[] conversions;
//(...)
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}

Both the definition and the initialization of the conversions field are missing.

  was:
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 generated class file we should be getting:
{code:java}
private static final org.apache.avro.Conversion<?>[] conversions;
//(...)
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}

Both the definition and the initialization of the conversions field are missing.


> 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.9.2, 1.11.3
>         Environment: apache maven, avro maven plugin, avro v1.11.3 or 1.9.2 
> (tried with both), code being generated either in Java 8 or 11.
> Faulty java generation happens in both maven running locally on intellij idea 
> and on jenkins pipelines.
> Issue happens in both windows and linux.
>            Reporter: Joan Soto Targa
>            Priority: Major
>
> In our company we're using both 1.9.2 and 1.11.3 versions of avro compiling 
> to Java 8 (or 11) 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 generated class file we should be getting:
> {code:java}
> private static final org.apache.avro.Conversion<?>[] conversions;
> //(...)
> 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}
> Both the definition and the initialization of the conversions field are 
> missing.



--
This message was sent by Atlassian Jira
(v8.20.10#820010)

Reply via email to