FloatLocaleConverter cannot parse 0
-----------------------------------

                 Key: BEANUTILS-351
                 URL: https://issues.apache.org/jira/browse/BEANUTILS-351
             Project: Commons BeanUtils
          Issue Type: Bug
          Components: Locale BeanUtils / Converters
    Affects Versions: 1.8.0
            Reporter: Lucian Chirita


FloatLocaleConverter fails to parse the "0" string, complaining that the value 
is not of type Float.

Doing new LocaleConvertUtilsBean().convert("0", Float.class, Locale.US, null) 
results in the following exception:

Exception in thread "main" org.apache.commons.beanutils.ConversionException: 
Supplied number is not of type Float: 0
        at 
org.apache.commons.beanutils.locale.converters.FloatLocaleConverter.parse(FloatLocaleConverter.java:222)
        at 
org.apache.commons.beanutils.locale.BaseLocaleConverter.convert(BaseLocaleConverter.java:232)
        at 
org.apache.commons.beanutils.locale.LocaleConvertUtilsBean.convert(LocaleConvertUtilsBean.java:285)
        at Code.main(Code.java:65)

Looking at the source of FloatLocaleConverter, line 221 which originally reads

if (posDouble < Float.MIN_VALUE || posDouble > Float.MAX_VALUE) {

should be changed to 

if ((posDouble > 0 && posDouble < Float.MIN_VALUE) || posDouble > 
Float.MAX_VALUE) {

in order to fix the bug.

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.

Reply via email to