You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@groovy.apache.org by "Andrew Preston (JIRA)" <ji...@apache.org> on 2016/01/04 22:36:40 UTC

[jira] [Commented] (GROOVY-7530) disjoint() does not work correctly if objects don't implement Comparable

    [ https://issues.apache.org/jira/browse/GROOVY-7530?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=15081857#comment-15081857 ] 

Andrew Preston commented on GROOVY-7530:
----------------------------------------

Hi Tobias - would you be able to raise this fix for priority?  We need to remediate vulnerability issues asap.

> disjoint() does not work correctly if objects don't implement Comparable
> ------------------------------------------------------------------------
>
>                 Key: GROOVY-7530
>                 URL: https://issues.apache.org/jira/browse/GROOVY-7530
>             Project: Groovy
>          Issue Type: Bug
>          Components: groovy-runtime
>    Affects Versions: 2.4.4
>            Reporter: Tobias Ahlers
>
> {code:java}
> class Foo {
>     private String name
>     Foo(String name) {
>         this.name = name
>     }
>     public boolean equals(Object o) {
>         if (this == o) return true
>         if (o == null || getClass() != o.getClass()) return false
>         Foo that = (Foo) o
>         return Objects.equals(name, that.name)
>     }
>     public int hashCode() {
>         return Objects.hash(name)
>     }
> }
> def a = [new Foo("foo")]
> def b = [new Foo("foo")]    
> assert !a.disjoint(b)
> {code}
> If disjoint() is used on a list with objects not implementing Comparable the wrong result is returned.
> intersect() shows the same wrong behavior.
> It's looks like the NumberAwareComparator not implementing the equals case as of commit 286532c is the problem.



--
This message was sent by Atlassian JIRA
(v6.3.4#6332)