avro
avro copied to clipboard
AVRO-3947: [Java] Support subclasses in custom LogicalType Conversions
What is the purpose of the change
Currently GenericData.resolveUnion(schema, datum)
will throw an AvroRuntimeException
if datum is a subclass (or any instance) of the target type of an applicable logical type Conversion. For instance
-
"ip-address"
logical type string converter to/fromjava.net.InetAddress
(withInet4Address
,Inet6Address
as subclasses) -
"json"
logical type string conversion to/from Jackson'sJsonNode
(withObjectNode
,ArrayNode
, etc as subclasses)
This PR fixes AVRO-3947.
Verifying this change
A unit test was added to validate that GenericData.resolveUnion(schema, datum)
behaves as intended.
Documentation
- Does this pull request introduce a new feature? no
- If yes, how is the feature documented? not applicable