Uploaded image for project: 'Apache Avro'
  1. Apache Avro
  2. AVRO-3947

GenericData resolveUnion throws AvroRuntimeException on LogicalType subclassing

    XMLWordPrintableJSON

Details

    • Bug
    • Status: Open
    • Major
    • Resolution: Unresolved
    • 1.12.0
    • None
    • java

    Description

      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)

       

      Attachments

        Issue Links

          Activity

            People

              Unassigned Unassigned
              tmoschou Terry Moschou
              Votes:
              0 Vote for this issue
              Watchers:
              1 Start watching this issue

              Dates

                Created:
                Updated:

                Time Tracking

                  Estimated:
                  Original Estimate - Not Specified
                  Not Specified
                  Remaining:
                  Remaining Estimate - 0h
                  0h
                  Logged:
                  Time Spent - 20m
                  20m