groovy-notifications mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Andrew White (JIRA)" <>
Subject [jira] [Created] (GROOVY-7876) ClassCastException when calling DefaultTypeTransformation#compareEqual
Date Mon, 27 Jun 2016 22:33:57 GMT
Andrew White created GROOVY-7876:

             Summary: ClassCastException when calling DefaultTypeTransformation#compareEqual
                 Key: GROOVY-7876
             Project: Groovy
          Issue Type: Bug
    Affects Versions: 2.4.6
            Reporter: Andrew White

It appears that comparing two objects that both implement comparable with DefaultTypeTransformation#compareEqual
is not safe in all cases. Consider enums for example, which throw exceptions when compared
to differing classes. 

This is using Eclipse Collections for pairs but the idea is the same in general. 

    enum E1 {A, B, C}
    enum E2 {D, E, F}

    def "test groovy oddness"() {
        def test = GroovyRuntimeUtil.equals(
            Tuples.pair(E1.A, 1), 
            Tuples.pair(E2.D, 1))

        assert test == false


	at java.lang.Enum.compareTo(
	at java.lang.Enum.compareTo(
	at org.eclipse.collections.impl.tuple.PairImpl.compareTo(
	at org.eclipse.collections.impl.tuple.PairImpl.compareTo(
	at com.GroovyTests.test groovy oddness(GroovyTests.groovy:36)

This message was sent by Atlassian JIRA

View raw message