[
https://issues.apache.org/jira/browse/OFBIZ-6291?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=14510829#comment-14510829
]
Gareth Carter commented on OFBIZ-6291:
--------------------------------------
What about comparing 2.001 and 2.0001? Lets say both numbers are BigDecimal in
both groovy and minilang.
In groovy, == is false, compareTo() is 1 and equals() is false.
In minilang, if 'if-compare-field' type is set to BigDecimal, the result is
true because compareBigDecimals sets the scale to the smallest scale and rounds
up, in this instance 2.0001 will result in 2.001 and compareTo equals 0.
Why is this done in minilang and no where else?
Is this correct? Condidering the same value in another type float/double/string
would be false?
What about com.ibm.icu.math.BigDecimal?
On further investigation, I doubt this will affect much in minilang considering
the default conversion type on if-compare and if-compare-field is String so
compareBigDecimals would only be called when type="BigDecimal"
eg:
<if-compare-field operator="equals" field="d1" to-field="e1" type="BigDecimal">
</if-compare-field>
> Update code to check for types rather than throw ClassCastException
> -------------------------------------------------------------------
>
> Key: OFBIZ-6291
> URL: https://issues.apache.org/jira/browse/OFBIZ-6291
> Project: OFBiz
> Issue Type: Improvement
> Components: framework
> Affects Versions: Trunk
> Reporter: Gareth Carter
> Priority: Trivial
> Attachments: LocalizedConverters.patch, minilang_compare.patch,
> minilang_compare_r1675655.patch
>
>
> framework/minilang/src/org/ofbiz/minilang/method/conditional/Compare.java
> framework/base/src/org/ofbiz/base/util/ObjectType.java
> framework/minilang/src/org/ofbiz/minilang/MiniLangUtil.java
> all throw ClassCastExceptions and are ignored instead of checking types
> This caused issues in debugging when adding a ClassCastException breakpoint
--
This message was sent by Atlassian JIRA
(v6.3.4#6332)