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