[
https://issues.apache.org/jira/browse/AVRO-3947?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel
]
ASF GitHub Bot updated AVRO-3947:
---------------------------------
Labels: pull-request-available (was: )
> GenericData resolveUnion throws AvroRuntimeException on LogicalType
> subclassing
> -------------------------------------------------------------------------------
>
> Key: AVRO-3947
> URL: https://issues.apache.org/jira/browse/AVRO-3947
> Project: Apache Avro
> Issue Type: Bug
> Components: java
> Affects Versions: 1.12.0
> Reporter: Terry Moschou
> Priority: Major
> Labels: pull-request-available
> Time Spent: 10m
> Remaining Estimate: 0h
>
> The current implementation of LogicalType Conversions in
> {{GenericData.resolveUnion(schema, datum)}} fails with
> {{AvroRuntimeException}} when the datum used is any instance of the type used
> by the converter. This is due to {{Class<?>}} being used as the key of map in
> {{{}GenericData.conversionsByClass{}}}, where as a better implementation
> would be to iterate over the applicable logical type converters, for each
> schema in the union and test if
> {{conversion.getConvertedType().isInstance(datum)}}
> Practical examples of logical type subclassing we are using:
> * {{"ip-address"}} logical type string converter to/from
> {{java.net.InetAddress}} (with Inet4Address, Inet6Address as subclasses)
> * {{"json"}} logical type string conversion to/from Jackson's JsonNode (with
> ObjectNode, ArrayNode, etc as subclasses)
>
--
This message was sent by Atlassian Jira
(v8.20.10#820010)