[ 
https://issues.apache.org/jira/browse/AVRO-1049?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel
 ]

Doug Cutting updated AVRO-1049:
-------------------------------

    Resolution: Fixed
        Status: Resolved  (was: Patch Available)

I committed this.
                
> 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
>            Assignee: Doug Cutting
>            Priority: Minor
>             Fix For: 1.7.0
>
>         Attachments: AVRO-1049.patch
>
>
> GenericData.Record#equals() does not 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:
> {code}
> @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
> }
> {code}
> See also:
> http://mail-archives.apache.org/mod_mbox/avro-user/201202.mbox/%[email protected]%3E

--
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

        

Reply via email to