commons-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From bugzi...@apache.org
Subject DO NOT REPLY [Bug 33841] New: - FloatLocaleConverter cannot parse negative values
Date Fri, 04 Mar 2005 10:06:33 GMT
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=33841>.
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=33841

           Summary: FloatLocaleConverter cannot parse negative values
           Product: Commons
           Version: unspecified
          Platform: PC
        OS/Version: Windows XP
            Status: NEW
          Severity: normal
          Priority: P2
         Component: Bean Utilities
        AssignedTo: commons-dev@jakarta.apache.org
        ReportedBy: paul@jeek.co.uk


Problem found in Build 1.7

LocaleBeanUtils.setProperty(bean, name, value);

Does not handle negative values. When processing negative values the 
FloatLocaleConverter.parse(value, pattern) throws a ConversionException because 
of the following if test: -

if(Math.abs(parsed.doubleValue() - parsed.floatValue()) > 
                                          parsed.floatValue() * 0.00001) {
  throw new ConversionException(...);
}

This test will always fail for a valid negative value because the 
multiplication by 0.00001 will result in a negative value which will be less 
then the abs subtraction.

A solution to this problem would be to check Math.abs(parsed.floatValue() * 
0.00001)

We also suffer from the previously reported problem of the locale converters 
not supporting boolean to get round this problem we have to determine the 
property type and call either LocaleBeanUtils.setProperty() or 
BeanUtils.setProperty() this would be made easier if the: -

protected Descriptor calculate(Object bean, String name) 

method was made public.

-- 
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: commons-dev-unsubscribe@jakarta.apache.org
For additional commands, e-mail: commons-dev-help@jakarta.apache.org


Mime
View raw message