Details
-
Bug
-
Status: Closed
-
Major
-
Resolution: Fixed
-
1.8.0
-
None
Description
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.