DO NOT REPLY TO THIS EMAIL, BUT PLEASE POST YOUR BUGĀ·
RELATED COMMENTS THROUGH THE WEB INTERFACE AVAILABLE AT
<http://issues.apache.org/bugzilla/show_bug.cgi?id=43656>.
ANY REPLY MADE TO THIS MESSAGE WILL NOT BE COLLECTED ANDĀ·
INSERTED IN THE BUG DATABASE.

http://issues.apache.org/bugzilla/show_bug.cgi?id=43656

           Summary: ELSupport.coerceToType modifies BigDecimal Values
           Product: Tomcat 6
           Version: 6.0.14
          Platform: Other
        OS/Version: other
            Status: NEW
          Severity: normal
          Priority: P2
         Component: Servlet & JSP API
        AssignedTo: [EMAIL PROTECTED]
        ReportedBy: [EMAIL PROTECTED]


If ELSupport.coerceToType is called with an BigDecimal instance as the first 
Parameter 'obj' and 
BigDecimal.class as type it should return the inputted value.

Instead the BigDecimal is converted into a double and back into a BigDecimal 
which leads to a diffenent 
value. This happens in Line 228:

        if (BigInteger.class.equals(type)) {
            if (number instanceof BigDecimal) {
                return ((BigDecimal) number).toBigInteger();
            }
            return BigInteger.valueOf(number.longValue()); // This leads to a 
different value.
        }

Example: Run the Method with new BigDecimal("0.19"), BigDecimal.class as 
parameters.
This should result in a BigDecimal with value 0.19. Instead i got 
0.190000000000000002220446049250313080847263336181640625.

 The easiest solution is to compare the class of the object to coerce with the 
target class and return the 
inputted value if the are equal in ELSupport.coerceToType Method:

public final static Object coerceToType(final Object obj, final Class type) 
throws 
IllegalArgumentException {
                if (type == null || Object.class.equals(type) || 
type.equals(obj.getClass())) {
                        return obj;
                }
...

-- 
Configure bugmail: http://issues.apache.org/bugzilla/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
You are the assignee for the bug, or are watching the assignee.

---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to