Hi Lukas! Yes, this sounds like a bug please file an issue.
On Wed, Oct 8, 2014 at 2:26 PM, Lukas Steiblys <[email protected]> wrote: > I realized now that “default” is a keyword in Java and can’t be used as > an enum value. The files were generated in python using the python Avro > library, where “default” is not a keyword and can be used freely. I assume > there should be a conversion somewhere in the Java Avro library, where a > dollar sign is automatically added for enum values that are Java keywords. > Is that actually the case? Why did it fail this time then? Should I file a > bug? > > Lukas > > *From:* Lukas Steiblys <[email protected]> > *Sent:* Wednesday, October 8, 2014 12:06 PM > *To:* [email protected] > *Subject:* Generated enum dollar sign in front of a symbol. > > Has anyone run into the problem where the generated java class for an > enum has a dollar sign for one enum value? > > The schema {"type": "enum", "name": "ButtonTypeID", "symbols": > ["default", "keyboard"]} generates the following class: > > public final class ButtonTypeID extends java.lang.Enum<ButtonTypeID> { > public static final ButtonTypeID default$; > public static final ButtonTypeID keyboard; > public static final org.apache.avro.Schema SCHEMA$; > public static ButtonTypeID[] values(); > public static ButtonTypeID valueOf(java.lang.String); > public static org.apache.avro.Schema getClassSchema(); > static {}; > } > > (this is what “javap ButtonTypeID.class” produces) > > When I try to read my data that has the “default” value for ButtonTypeID, > I get the exception: > > java.lang.IllegalArgumentException: No enum constant ButtonTypeID.default > at java.lang.Enum.valueOf(Enum.java:236) > at > org.apache.avro.specific.SpecificData.createEnum(SpecificData.java:106) > at > org.apache.avro.generic.GenericDatumReader.createEnum(GenericDatumReader.java:205)... > > Strangely, everything was working fine a day before. Where is this dollar > sign coming from? > > Lukas > > -- Sean
