You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@commons.apache.org by "Goran Hacek (JIRA)" <ji...@apache.org> on 2009/10/14 13:46:31 UTC

[jira] Created: (COLLECTIONS-340) NOPClosure has a broken equals method

NOPClosure has a broken equals method
-------------------------------------

                 Key: COLLECTIONS-340
                 URL: https://issues.apache.org/jira/browse/COLLECTIONS-340
             Project: Commons Collections
          Issue Type: Bug
          Components: Functor
            Reporter: Goran Hacek
            Priority: Minor
             Fix For: Generics


Equals method of NOPClosure class doesn't follow objects equals contract. It isn't symmetric nor transitive and it is just plain wrong.

Following code evaluates to true on most (if not all) JVM implementations:
{noformat} NOPClosure.INSTANCE.equals(new Integer(System.identityHashCode(NOPClosure.INSTANCE))) {noformat} 

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.


[jira] Resolved: (COLLECTIONS-340) NOPClosure has a broken equals method

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

Matt Benson resolved COLLECTIONS-340.
-------------------------------------

    Resolution: Fixed

Rather than remove it -- any NOPClosure, after all, _should_ be equal to any other -- I fixed it.  Committed revision 825148.

> NOPClosure has a broken equals method
> -------------------------------------
>
>                 Key: COLLECTIONS-340
>                 URL: https://issues.apache.org/jira/browse/COLLECTIONS-340
>             Project: Commons Collections
>          Issue Type: Bug
>          Components: Functor
>            Reporter: Goran Hacek
>            Priority: Minor
>             Fix For: Generics
>
>
> Equals method of NOPClosure class doesn't follow objects equals contract. It isn't symmetric nor transitive and it is just plain wrong.
> Following code evaluates to true on most (if not all) JVM implementations:
> {noformat} NOPClosure.INSTANCE.equals(new Integer(System.identityHashCode(NOPClosure.INSTANCE))) {noformat} 

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.


[jira] Commented: (COLLECTIONS-340) NOPClosure has a broken equals method

Posted by "Goran Hacek (JIRA)" <ji...@apache.org>.
    [ https://issues.apache.org/jira/browse/COLLECTIONS-340?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=12765525#action_12765525 ] 

Goran Hacek commented on COLLECTIONS-340:
-----------------------------------------

None of the classes in "org.apache.commons.collections.functors" package implement equals() or hashCode() so why should NOPClosure be any different.

I suggest removal of both equals() and hashCode()  from NOPClosure.

> NOPClosure has a broken equals method
> -------------------------------------
>
>                 Key: COLLECTIONS-340
>                 URL: https://issues.apache.org/jira/browse/COLLECTIONS-340
>             Project: Commons Collections
>          Issue Type: Bug
>          Components: Functor
>            Reporter: Goran Hacek
>            Priority: Minor
>             Fix For: Generics
>
>
> Equals method of NOPClosure class doesn't follow objects equals contract. It isn't symmetric nor transitive and it is just plain wrong.
> Following code evaluates to true on most (if not all) JVM implementations:
> {noformat} NOPClosure.INSTANCE.equals(new Integer(System.identityHashCode(NOPClosure.INSTANCE))) {noformat} 

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.