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

Builder API fails to substitute default values for enum types

    Details

    • Type: Bug
    • Status: Closed
    • Priority: Major
    • Resolution: Fixed
    • Affects Version/s: 1.6.1
    • Fix Version/s: 1.6.2
    • Component/s: java
    • Labels:
      None

      Description

      If a schema has an enum type with a default value, and the Builder API is used to automatically substitute the default value on build(), a ClassCastException is thrown. The reason is that the default value resolves to a GenericData.EnumSymbol. The specific builder then attempts to cast this value to the corresponding Java enum type, which fails. Here is an example stack trace:

      org.apache.avro.AvroRuntimeException: java.lang.ClassCastException: org.apache.avro.generic.GenericData$EnumSymbol cannot be cast to org.apache.avro.ipc.specific.PrivacyType
      	at org.apache.avro.ipc.specific.Person$Builder.build(Person.java:410)
      	at org.apache.avro.specific.TestSpecificRecordBuilder.testSpecificBuilder(TestSpecificRecordBuilder.java:51)
      Caused by: java.lang.ClassCastException: org.apache.avro.generic.GenericData$EnumSymbol cannot be cast to org.apache.avro.ipc.specific.PrivacyType
      	at org.apache.avro.ipc.specific.Person$Builder.build(Person.java:407)
      	... 24 more
      

        Attachments

        1. AVRO-1020.patch
          4 kB
          Doug Cutting
        2. AVRO-1020.bug.patch
          0.6 kB
          James Baldassari

          Activity

            People

            • Assignee:
              cutting Doug Cutting
              Reporter:
              jbaldassari James Baldassari
            • Votes:
              0 Vote for this issue
              Watchers:
              0 Start watching this issue

              Dates

              • Created:
                Updated:
                Resolved: