Details
-
Bug
-
Status: Open
-
Major
-
Resolution: Unresolved
-
1.12.0
-
None
-
None
-
Avro 1.12.0
JDK 21
Maven
Description
There is a unit test which shows what's the issue:
Most important part is block of code around line 40.
In version 1.12.0 implementation of equals() has been changed to
public boolean equals(final Object o) { if (!(o instanceof Collection)) { return false; } return GenericData.get().compare(this, o, this.getSchema()) == 0; }
which fails when logical types are used.
More precisely: when record's field is an array of union of "null" and logical type.
Basically when originalPoi and deserializedPoi are Java class instances and
originalPoi.getLocations().equals(deserializedPoi.getLocations()) == true
then
deserializedPoi.getLocations().equals(originalPoi.getLocations())
should be also true but it throws an exception:
org.apache.avro.AvroRuntimeException: Unknown datum type com.rtbhouse.custom.logical.types.LatLon: LatLon[latitude=30.123, longitude=-90.98762] at org.apache.avro.generic.GenericData.getSchemaName(GenericData.java:975) at org.apache.avro.generic.GenericData.resolveUnion(GenericData.java:934) at org.apache.avro.generic.GenericData.compare(GenericData.java:1310) at org.apache.avro.generic.GenericData.compare(GenericData.java:1286) at org.apache.avro.generic.GenericData.compare(GenericData.java:1300) at org.apache.avro.generic.GenericData.compare(GenericData.java:1201) at org.apache.avro.generic.GenericData$AbstractArray.equals(GenericData.java:357) at com.rtbhouse.custom.logical.types.SerializeDeserializeTest.shouldSerializeAndDeserializeAvro(SerializeDeserializeTest.java:46)