commons-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "David Birch (JIRA)" <>
Subject [jira] Created: (BEANUTILS-276) Exceptions when setting properties to null (specific types only)
Date Wed, 02 May 2007 10:09:15 GMT
Exceptions when setting properties to null (specific types only)

                 Key: BEANUTILS-276
             Project: Commons BeanUtils
          Issue Type: Bug
          Components: ConvertUtils & Converters
    Affects Versions: 1.7.0
         Environment: java 1.4.2, 1.5.0
            Reporter: David Birch

for the following types attempting to set a property to null will result in an Exception



all primitive wrappers work fine, as does java.util.Date

sample stacktrace is
Failed Set empty [bigDecimal1]
org.apache.commons.beanutils.ConversionException: No value specified
	at org.apache.commons.beanutils.converters.BigDecimalConverter.convert(
	at org.apache.commons.beanutils.ConvertUtilsBean.convert(
	at org.apache.commons.beanutils.BeanUtilsBean.setProperty(
	at org.apache.commons.beanutils.BeanUtils.setProperty(
	at com.marsh.ste.testing.steps.DataStepUT.testChanges(

The converter classes seem to sort of have an option to handle null inputs by returning a
default value - from BigDecimalConverter.convert()

      if (value == null) {
            if (useDefault) {
                return (defaultValue);
            } else {
                throw new ConversionException("No value specified");

though i am not totally sure, might be better to fix this in the BeanUtilsBean.setProperty
method, add some other cases - block starting line 1001

            if ((value instanceof String) || (value == null)) {
                newValue = getConvertUtils().convert((String) value, type);
            } else if (value instanceof String[]) {
                newValue = getConvertUtils().convert(((String[]) value)[0],
            } else if (getConvertUtils().lookup(value.getClass()) != null) {
                newValue = getConvertUtils().convert(value.toString(), type);
            } else {
                newValue = value;


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

To unsubscribe, e-mail:
For additional commands, e-mail:

View raw message