[ https://issues.apache.org/jira/browse/AVRO-336?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]
Doug Cutting reassigned AVRO-336: --------------------------------- Assignee: Doug Cutting > Equals() on SpecificRecord fails (java) > --------------------------------------- > > Key: AVRO-336 > URL: https://issues.apache.org/jira/browse/AVRO-336 > Project: Avro > Issue Type: Bug > Components: java > Affects Versions: 1.3.0 > Reporter: Scott Carey > Assignee: Doug Cutting > Fix For: 1.3.0 > > Attachments: AVRO-336.patch > > > rev 899520, trunk. > Calling equals() on an object generated by the SpecificAPI fails. > The object is a record with several fields, one is an array. This object can > serialize and deserialize, binary and json. But equals() fails, as well as > hashCode() in some cases. > It fails in Schema.java, line 217. > {code} > /** If this is an array, returns its element type. */ > public Schema getElementType() { > throw new AvroRuntimeException("Not an array: "+this); > } > {code} > This looks unimplemented. > The stack trace is: > {noformat} > Exception in thread "main" org.apache.avro.AvroRuntimeException: Not an > array: > {"type":"record","name":"Variable","namespace":"com.rr.avro","fields":[{"name":"variableId","type":"int"},{"name":"selectedValue","type":"string"}]} > at org.apache.avro.Schema.getElementType(Schema.java:217) > at org.apache.avro.generic.GenericData.compare(GenericData.java:468) > at org.apache.avro.specific.SpecificData.compare(SpecificData.java:250) > at org.apache.avro.specific.SpecificData.compare(SpecificData.java:242) > at > org.apache.avro.specific.SpecificRecordBase.compareTo(SpecificRecordBase.java:45) > at > org.apache.avro.specific.SpecificRecordBase.equals(SpecificRecordBase.java:35) > {noformat} > That record is the element type of the array, so I think this is just due to > the implementation being incomplete. > The specific compiler could also generate equals() methods (which would be > more efficient than traversing the schema). I wonder if eclipse's "generate > hashcode and equals" code is usable. -- This message is automatically generated by JIRA. - You can reply to this email to add a comment to the issue online.