commons-issues mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Senen de Diego (JIRA)" <j...@apache.org>
Subject [jira] [Commented] (OGNL-173) OgnlOps.equal fails for two non-numeric objects that are not Comparable
Date Tue, 14 Aug 2012 23:27:38 GMT

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

Senen de Diego commented on OGNL-173:
-------------------------------------

I agree completely with Tony Stevenson.

If I'm comparing two objects of the same class (not Number) and o1.equals(o2) returns false,
I want OgnlOps.isEqual(o1,o2) to return false. And even if the class is Comparable and o1.compareTo(o2)
returns 0, OgnlOps.isEqual() should be consistent with equal(), not with compareTo(), and
also return false.

Of course, throwing an Exception, which is what happens with the current implementation when
the class is not Comparable, is the worst election.

I believe the call to compareWithConversion has to be done only after checking that both objects
are instances of Number, otherwise o1.equals(o2) should suffice.
                
> OgnlOps.equal fails for two non-numeric objects that are not Comparable 
> ------------------------------------------------------------------------
>
>                 Key: OGNL-173
>                 URL: https://issues.apache.org/jira/browse/OGNL-173
>             Project: Commons OGNL
>          Issue Type: Bug
>            Reporter: David Mansfield
>
> OgnlOps.equal calls OgnlOps.isEqual, which, for two objects of some class X which are
not equal according to X.equals() method, will then call OgnlOps.compareWithConversion. This
method will throw an IllegalArgumentException on or around line 92 unless the class is a Comparable.
 This exception is wrong or is not caught properly in the isEqual method.
> How about wrapping the compareWithConversion in isEqual in a try/catch?
> I'm currently using ognl 3.0.1 but I checked latest code in SVN and it doesn't appear
any different.

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

        

Mime
View raw message