Du Liu created AVRO-3224:
----------------------------

             Summary: Wrong deserialisation when using ReflectData.AllowNull 
with custom LogicalType conversions
                 Key: AVRO-3224
                 URL: https://issues.apache.org/jira/browse/AVRO-3224
             Project: Apache Avro
          Issue Type: Bug
          Components: java
    Affects Versions: 1.10.2
            Reporter: Du Liu
         Attachments: ReflectData.AllowNull.get doesnt work.png, 
ReflectData.get works.png, class_and_conversion.png, tests.txt

If a class contains both a java.time.LocalDate field and a java.sql.Date field, 
serialising an instance of the class using ReflectData.*AllowNull* with two 
conversions that both convert to avro date logical type (e.g. one converts 
java.time.LocalDate to avro date, the other converts java.sql.Date to avro 
date) is done correctly, but when deserialising the data back, the LocalDate 
field of the deserialised instance incorrectly contains a java.sql.Date (or the 
Date field incorrectly contains a LocalDate depending on which conversions is 
added last).

This only happens when using ReflectData.*AllowNull*.get(). ReflectData.get() 
can correctly deserialised data back.

A working example (using ReflectData.get()):

!ReflectData.get works.png!

 

A not working example (using ReflectData.AllowNull.get()):

!ReflectData.AllowNull.get doesnt work.png!

The class and conversion: 

!class_and_conversion.png!

 

These tests are included in the attached patch file:  [^tests.txt]



--
This message was sent by Atlassian Jira
(v8.3.4#803005)

Reply via email to