GenericData.Record#equals() does not return false when the schemas are not equal
--------------------------------------------------------------------------------
Key: AVRO-1049
URL: https://issues.apache.org/jira/browse/AVRO-1049
Project: Avro
Issue Type: Bug
Components: java
Affects Versions: 1.6.0
Reporter: Andrew Kenworthy
Priority: Minor
This does look like a bug in GenericData.Record#equals(). It should
return false when the schemas are not equal. It currently only checks
the schema names as a performance optimization; this test code illustrates the
issue:
@Test
public void test() {
Schema schema1 = Schema.createRecord("test_record", null, "my.namespace",
false);
List<Field> fields1 = new ArrayList<Field>();
fields1.add(new Field("attribute1", Schema.create(Schema.Type.STRING), null,
null, Order.IGNORE));
schema1.setFields(fields1);
Schema schema2 = Schema.createRecord("test_record", null, "my.namespace",
false);
List<Field> fields2 = new ArrayList<Field>();
fields2.add(new Field("attribute1", Schema.create(Schema.Type.STRING), null,
null, Order.ASCENDING));
schema2.setFields(fields2);
GenericRecord record1 = new GenericData.Record(schema1);
record1.put("attribute1", "1");
GenericRecord record2 = new GenericData.Record(schema2);
record2.put("attribute1", "2");
System.out.println(record1.equals(record2)); // returns TRUE
System.out.println(record2.equals(record1)); // returns FALSE
}
--
This message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators:
https://issues.apache.org/jira/secure/ContactAdministrators!default.jspa
For more information on JIRA, see: http://www.atlassian.com/software/jira