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

Builder API fails to substitute default values for enum types

    XMLWordPrintableJSON

Details

    • Bug
    • Status: Closed
    • Major
    • Resolution: Fixed
    • 1.6.1
    • 1.6.2
    • java
    • 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

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

            Dates

              Created:
              Updated:
              Resolved: