empire-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Rainer Döbele (JIRA) <empire-db-...@incubator.apache.org>
Subject [jira] [Commented] (EMPIREDB-171) ObjectUtils.compareEquals fails on BigDecimal
Date Tue, 02 Oct 2012 11:35:07 GMT

    [ https://issues.apache.org/jira/browse/EMPIREDB-171?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=13467619#comment-13467619

Rainer Döbele commented on EMPIREDB-171:

I have had a look at this and Daniel is right.
The intention of that method is to check whether two values are equal. It will even return
true even if types don't match and e.g. one is a string and the other a number but both represent
the same value.
In this case both values are of type BigDecimal and both have a value of 50.
To my own suprise BigDecimal.equal() returns false although everybody knows that 50 and 50.00
are two representations of the same value.
I think this is a bug in Java.
BigDecimal.compareTo() however works.
I would suggest to check for the comparable interface and use that method instead of equals()
(I'll probably fix this and I'll check it in later)

> ObjectUtils.compareEquals fails on BigDecimal
> ---------------------------------------------
>                 Key: EMPIREDB-171
>                 URL: https://issues.apache.org/jira/browse/EMPIREDB-171
>             Project: Empire-DB
>          Issue Type: Bug
>          Components: Core
>    Affects Versions: empire-db-2.4.0
>            Reporter: Daniel Weidele
>            Priority: Critical
>   Original Estimate: 1h
>  Remaining Estimate: 1h
> Observed:
> When comparing a BigDecimal with internal value e.g. '50' to another BigDecimal with
internal value '50.00' ObjectUtils.compareEquals returns false as it internally forwards to
the BigDecimal.equals method, which also relies on internal BigDecimal properties such as
scale, etc.
> Expected:
> ObjectUtils.compareEquals should return true when comparing e.g. '50' to '50.00'

This message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators
For more information on JIRA, see: http://www.atlassian.com/software/jira

View raw message