You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@avro.apache.org by "Douglas Kaminsky (JIRA)" <ji...@apache.org> on 2011/04/05 23:00:05 UTC

[jira] [Created] (AVRO-796) Problems using Schema.equals() method

Problems using Schema.equals() method
-------------------------------------

                 Key: AVRO-796
                 URL: https://issues.apache.org/jira/browse/AVRO-796
             Project: Avro
          Issue Type: Bug
          Components: java
    Affects Versions: 1.5.0
            Reporter: Douglas Kaminsky


I was writing some code that dynamically creates schemas based on existing schemas and noticed when I was compiling the schemas I needed to reconstruct that the size of my java.util.Set did not reflect the number of times I called the .add method on that set. Naturally, I was led to investigate the schema.equals method, and noticed some alarming issues.

It seems that the current logic reports that two schemas are equal IFF they are both the same in memory OR they are both schemas of the same type with the same props. There are several issues that seem to be present here:

1) schema.equals(null) throws an exception instead of returning false as one would expect
2) Two schemas of the same type with a different name or documentation are considered equal (this may or may not be a "feature")


--
This message is automatically generated by JIRA.
For more information on JIRA, see: http://www.atlassian.com/software/jira

[jira] [Updated] (AVRO-796) Problems using Schema.equals() method

Posted by "Douglas Kaminsky (JIRA)" <ji...@apache.org>.
     [ https://issues.apache.org/jira/browse/AVRO-796?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Douglas Kaminsky updated AVRO-796:
----------------------------------

    Description: Schema.equals() does not properly handle null argument - the usual expected behavior is that it should return false.  (was: I was writing some code that dynamically creates schemas based on existing schemas and noticed when I was compiling the schemas I needed to reconstruct that the size of my java.util.Set did not reflect the number of times I called the .add method on that set. Naturally, I was led to investigate the schema.equals method, and noticed some alarming issues.

It seems that the current logic reports that two schemas are equal IFF they are both the same in memory OR they are both schemas of the same type with the same props. There are several issues that seem to be present here:

1) schema.equals(null) throws an exception instead of returning false as one would expect
2) Two schemas of the same type with a different name or documentation are considered equal (this may or may not be a "feature")
)
       Priority: Minor  (was: Major)

> Problems using Schema.equals() method
> -------------------------------------
>
>                 Key: AVRO-796
>                 URL: https://issues.apache.org/jira/browse/AVRO-796
>             Project: Avro
>          Issue Type: Bug
>          Components: java
>    Affects Versions: 1.5.0
>            Reporter: Douglas Kaminsky
>            Priority: Minor
>
> Schema.equals() does not properly handle null argument - the usual expected behavior is that it should return false.

--
This message is automatically generated by JIRA.
For more information on JIRA, see: http://www.atlassian.com/software/jira

[jira] [Commented] (AVRO-796) Problems using Schema.equals() method

Posted by "Douglas Kaminsky (JIRA)" <ji...@apache.org>.
    [ https://issues.apache.org/jira/browse/AVRO-796?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=13016121#comment-13016121 ] 

Douglas Kaminsky commented on AVRO-796:
---------------------------------------

Ditto for various typed schema subclasses

> Problems using Schema.equals() method
> -------------------------------------
>
>                 Key: AVRO-796
>                 URL: https://issues.apache.org/jira/browse/AVRO-796
>             Project: Avro
>          Issue Type: Bug
>          Components: java
>    Affects Versions: 1.5.0
>            Reporter: Douglas Kaminsky
>            Priority: Minor
>
> Schema.equals() does not properly handle null argument - the usual expected behavior is that it should return false.

--
This message is automatically generated by JIRA.
For more information on JIRA, see: http://www.atlassian.com/software/jira

[jira] [Resolved] (AVRO-796) Problems using Schema.equals() method

Posted by "Douglas Kaminsky (JIRA)" <ji...@apache.org>.
     [ https://issues.apache.org/jira/browse/AVRO-796?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Douglas Kaminsky resolved AVRO-796.
-----------------------------------

    Resolution: Not A Problem

Per comments, resolving as not a problem. Please correct status if you'd prefer a different one.

> Problems using Schema.equals() method
> -------------------------------------
>
>                 Key: AVRO-796
>                 URL: https://issues.apache.org/jira/browse/AVRO-796
>             Project: Avro
>          Issue Type: Bug
>          Components: java
>    Affects Versions: 1.5.0
>            Reporter: Douglas Kaminsky
>            Priority: Minor
>         Attachments: AVRO-796.patch
>
>
> Schema.equals() does not properly handle null argument - the usual expected behavior is that it should return false.

--
This message is automatically generated by JIRA.
For more information on JIRA, see: http://www.atlassian.com/software/jira

        

[jira] [Updated] (AVRO-796) Problems using Schema.equals() method

Posted by "Doug Cutting (JIRA)" <ji...@apache.org>.
     [ https://issues.apache.org/jira/browse/AVRO-796?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Doug Cutting updated AVRO-796:
------------------------------

    Attachment: AVRO-796.patch

I believe the null case is handled by instanceof in the equals implementation for each Schema subclass.

http://java.sun.com/docs/books/jls/third_edition/html/expressions.html#15.20.2

I've attached an explicit test for this in a method that's called for each type of schema, and this passes for me. 

> Problems using Schema.equals() method
> -------------------------------------
>
>                 Key: AVRO-796
>                 URL: https://issues.apache.org/jira/browse/AVRO-796
>             Project: Avro
>          Issue Type: Bug
>          Components: java
>    Affects Versions: 1.5.0
>            Reporter: Douglas Kaminsky
>            Priority: Minor
>         Attachments: AVRO-796.patch
>
>
> Schema.equals() does not properly handle null argument - the usual expected behavior is that it should return false.

--
This message is automatically generated by JIRA.
For more information on JIRA, see: http://www.atlassian.com/software/jira

[jira] [Commented] (AVRO-796) Problems using Schema.equals() method

Posted by "Douglas Kaminsky (JIRA)" <ji...@apache.org>.
    [ https://issues.apache.org/jira/browse/AVRO-796?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=13016226#comment-13016226 ] 

Douglas Kaminsky commented on AVRO-796:
---------------------------------------

So it is - seems to be okay - sorry, I originally had another issue and thought this was the cause, but i was incorrect - the additional test is a great safeguard for future refactoring and I hope it will become part of the next release. Otherwise, I suppose this is not a bug.

> Problems using Schema.equals() method
> -------------------------------------
>
>                 Key: AVRO-796
>                 URL: https://issues.apache.org/jira/browse/AVRO-796
>             Project: Avro
>          Issue Type: Bug
>          Components: java
>    Affects Versions: 1.5.0
>            Reporter: Douglas Kaminsky
>            Priority: Minor
>         Attachments: AVRO-796.patch
>
>
> Schema.equals() does not properly handle null argument - the usual expected behavior is that it should return false.

--
This message is automatically generated by JIRA.
For more information on JIRA, see: http://www.atlassian.com/software/jira