You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@commons.apache.org by "David Birch (JIRA)" <ji...@apache.org> on 2007/05/02 12:09:15 UTC
[jira] Created: (BEANUTILS-276) Exceptions when setting properties
to null (specific types only)
Exceptions when setting properties to null (specific types only)
----------------------------------------------------------------
Key: BEANUTILS-276
URL: https://issues.apache.org/jira/browse/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
java.math.BigDecimal
java.math.BigInteger
java.net.URL
java.io.File
java.sql.Date
java.sql.Time
java.sql.Timestamp
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(BigDecimalConverter.java:103)
at org.apache.commons.beanutils.ConvertUtilsBean.convert(ConvertUtilsBean.java:428)
at org.apache.commons.beanutils.BeanUtilsBean.setProperty(BeanUtilsBean.java:1002)
at org.apache.commons.beanutils.BeanUtils.setProperty(BeanUtils.java:313)
at com.marsh.ste.testing.steps.DataStepUT.testChanges(DataStepUT.java:52)
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],
type);
} else if (getConvertUtils().lookup(value.getClass()) != null) {
newValue = getConvertUtils().convert(value.toString(), type);
} else {
newValue = value;
}
cheers
David
--
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: commons-dev-unsubscribe@jakarta.apache.org
For additional commands, e-mail: commons-dev-help@jakarta.apache.org
[jira] Resolved: (BEANUTILS-276) Exceptions when setting properties
to null (specific types only)
Posted by "Niall Pemberton (JIRA)" <ji...@apache.org>.
[ https://issues.apache.org/jira/browse/BEANUTILS-276?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]
Niall Pemberton resolved BEANUTILS-276.
---------------------------------------
Resolution: Invalid
You're right that the individual converters have the option to provide a default value (which can be null) rather than throw an exception. So you need to register instances of those converters which are configured in that way. For example
BigDecimal defaultValue = new BigDecimal("0.0");
Converter bdc = new BigDecimalConverter(defaultValue);
ConvertUtils.register(bdc, BigDecimal.class);
> Exceptions when setting properties to null (specific types only)
> ----------------------------------------------------------------
>
> Key: BEANUTILS-276
> URL: https://issues.apache.org/jira/browse/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 using BeanUtils.setProperty(java.lang.Object, java.lang.String, java.lang.Object) will result in an Exception
> java.math.BigDecimal
> java.math.BigInteger
> java.net.URL
> java.io.File
> java.sql.Date
> java.sql.Time
> java.sql.Timestamp
> 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(BigDecimalConverter.java:103)
> at org.apache.commons.beanutils.ConvertUtilsBean.convert(ConvertUtilsBean.java:428)
> at org.apache.commons.beanutils.BeanUtilsBean.setProperty(BeanUtilsBean.java:1002)
> at org.apache.commons.beanutils.BeanUtils.setProperty(BeanUtils.java:313)
> at com.marsh.ste.testing.steps.DataStepUT.testChanges(DataStepUT.java:52)
> 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],
> type);
> } else if (getConvertUtils().lookup(value.getClass()) != null) {
> newValue = getConvertUtils().convert(value.toString(), type);
> } else {
> newValue = value;
> }
> cheers
> David
--
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: commons-dev-unsubscribe@jakarta.apache.org
For additional commands, e-mail: commons-dev-help@jakarta.apache.org
[jira] Resolved: (BEANUTILS-276) Exceptions when setting properties
to null (specific types only)
Posted by "Niall Pemberton (JIRA)" <ji...@apache.org>.
[ https://issues.apache.org/jira/browse/BEANUTILS-276?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]
Niall Pemberton resolved BEANUTILS-276.
---------------------------------------
Resolution: Won't Fix
> Exceptions when setting properties to null (specific types only)
> ----------------------------------------------------------------
>
> Key: BEANUTILS-276
> URL: https://issues.apache.org/jira/browse/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 using BeanUtils.setProperty(java.lang.Object, java.lang.String, java.lang.Object) will result in an Exception
> java.math.BigDecimal
> java.math.BigInteger
> java.net.URL
> java.io.File
> java.sql.Date
> java.sql.Time
> java.sql.Timestamp
> 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(BigDecimalConverter.java:103)
> at org.apache.commons.beanutils.ConvertUtilsBean.convert(ConvertUtilsBean.java:428)
> at org.apache.commons.beanutils.BeanUtilsBean.setProperty(BeanUtilsBean.java:1002)
> at org.apache.commons.beanutils.BeanUtils.setProperty(BeanUtils.java:313)
> at com.marsh.ste.testing.steps.DataStepUT.testChanges(DataStepUT.java:52)
> 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],
> type);
> } else if (getConvertUtils().lookup(value.getClass()) != null) {
> newValue = getConvertUtils().convert(value.toString(), type);
> } else {
> newValue = value;
> }
> cheers
> David
--
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: commons-dev-unsubscribe@jakarta.apache.org
For additional commands, e-mail: commons-dev-help@jakarta.apache.org
[jira] Reopened: (BEANUTILS-276) Exceptions when setting properties
to null (specific types only)
Posted by "David Birch (JIRA)" <ji...@apache.org>.
[ https://issues.apache.org/jira/browse/BEANUTILS-276?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]
David Birch reopened BEANUTILS-276:
-----------------------------------
Hi,
sorry, but i can't really see where the logic lies in not being able to set any of those types to null using the std config of converters - i realise that each of the types mentioned do not have no-args constructors, but we're not trying to construct, we're just trying to set a bean property with a legal value (null).
thanks
David
> Exceptions when setting properties to null (specific types only)
> ----------------------------------------------------------------
>
> Key: BEANUTILS-276
> URL: https://issues.apache.org/jira/browse/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 using BeanUtils.setProperty(java.lang.Object, java.lang.String, java.lang.Object) will result in an Exception
> java.math.BigDecimal
> java.math.BigInteger
> java.net.URL
> java.io.File
> java.sql.Date
> java.sql.Time
> java.sql.Timestamp
> 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(BigDecimalConverter.java:103)
> at org.apache.commons.beanutils.ConvertUtilsBean.convert(ConvertUtilsBean.java:428)
> at org.apache.commons.beanutils.BeanUtilsBean.setProperty(BeanUtilsBean.java:1002)
> at org.apache.commons.beanutils.BeanUtils.setProperty(BeanUtils.java:313)
> at com.marsh.ste.testing.steps.DataStepUT.testChanges(DataStepUT.java:52)
> 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],
> type);
> } else if (getConvertUtils().lookup(value.getClass()) != null) {
> newValue = getConvertUtils().convert(value.toString(), type);
> } else {
> newValue = value;
> }
> cheers
> David
--
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: commons-dev-unsubscribe@jakarta.apache.org
For additional commands, e-mail: commons-dev-help@jakarta.apache.org
[jira] Updated: (BEANUTILS-276) Exceptions when setting properties
to null (specific types only)
Posted by "David Birch (JIRA)" <ji...@apache.org>.
[ https://issues.apache.org/jira/browse/BEANUTILS-276?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]
David Birch updated BEANUTILS-276:
----------------------------------
Description:
for the following types attempting to set a property to null using BeanUtils.setProperty(java.lang.Object, java.lang.String, java.lang.Object) will result in an Exception
java.math.BigDecimal
java.math.BigInteger
java.net.URL
java.io.File
java.sql.Date
java.sql.Time
java.sql.Timestamp
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(BigDecimalConverter.java:103)
at org.apache.commons.beanutils.ConvertUtilsBean.convert(ConvertUtilsBean.java:428)
at org.apache.commons.beanutils.BeanUtilsBean.setProperty(BeanUtilsBean.java:1002)
at org.apache.commons.beanutils.BeanUtils.setProperty(BeanUtils.java:313)
at com.marsh.ste.testing.steps.DataStepUT.testChanges(DataStepUT.java:52)
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],
type);
} else if (getConvertUtils().lookup(value.getClass()) != null) {
newValue = getConvertUtils().convert(value.toString(), type);
} else {
newValue = value;
}
cheers
David
was:
for the following types attempting to set a property to null will result in an Exception
java.math.BigDecimal
java.math.BigInteger
java.net.URL
java.io.File
java.sql.Date
java.sql.Time
java.sql.Timestamp
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(BigDecimalConverter.java:103)
at org.apache.commons.beanutils.ConvertUtilsBean.convert(ConvertUtilsBean.java:428)
at org.apache.commons.beanutils.BeanUtilsBean.setProperty(BeanUtilsBean.java:1002)
at org.apache.commons.beanutils.BeanUtils.setProperty(BeanUtils.java:313)
at com.marsh.ste.testing.steps.DataStepUT.testChanges(DataStepUT.java:52)
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],
type);
} else if (getConvertUtils().lookup(value.getClass()) != null) {
newValue = getConvertUtils().convert(value.toString(), type);
} else {
newValue = value;
}
cheers
David
> Exceptions when setting properties to null (specific types only)
> ----------------------------------------------------------------
>
> Key: BEANUTILS-276
> URL: https://issues.apache.org/jira/browse/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 using BeanUtils.setProperty(java.lang.Object, java.lang.String, java.lang.Object) will result in an Exception
> java.math.BigDecimal
> java.math.BigInteger
> java.net.URL
> java.io.File
> java.sql.Date
> java.sql.Time
> java.sql.Timestamp
> 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(BigDecimalConverter.java:103)
> at org.apache.commons.beanutils.ConvertUtilsBean.convert(ConvertUtilsBean.java:428)
> at org.apache.commons.beanutils.BeanUtilsBean.setProperty(BeanUtilsBean.java:1002)
> at org.apache.commons.beanutils.BeanUtils.setProperty(BeanUtils.java:313)
> at com.marsh.ste.testing.steps.DataStepUT.testChanges(DataStepUT.java:52)
> 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],
> type);
> } else if (getConvertUtils().lookup(value.getClass()) != null) {
> newValue = getConvertUtils().convert(value.toString(), type);
> } else {
> newValue = value;
> }
> cheers
> David
--
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: commons-dev-unsubscribe@jakarta.apache.org
For additional commands, e-mail: commons-dev-help@jakarta.apache.org
[jira] Commented: (BEANUTILS-276) Exceptions when setting
properties to null (specific types only)
Posted by "David Birch (JIRA)" <ji...@apache.org>.
[ https://issues.apache.org/jira/browse/BEANUTILS-276?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel#action_12493135 ]
David Birch commented on BEANUTILS-276:
---------------------------------------
PS. thanks for the explicit example for Config! this will give us a workaround
> Exceptions when setting properties to null (specific types only)
> ----------------------------------------------------------------
>
> Key: BEANUTILS-276
> URL: https://issues.apache.org/jira/browse/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 using BeanUtils.setProperty(java.lang.Object, java.lang.String, java.lang.Object) will result in an Exception
> java.math.BigDecimal
> java.math.BigInteger
> java.net.URL
> java.io.File
> java.sql.Date
> java.sql.Time
> java.sql.Timestamp
> 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(BigDecimalConverter.java:103)
> at org.apache.commons.beanutils.ConvertUtilsBean.convert(ConvertUtilsBean.java:428)
> at org.apache.commons.beanutils.BeanUtilsBean.setProperty(BeanUtilsBean.java:1002)
> at org.apache.commons.beanutils.BeanUtils.setProperty(BeanUtils.java:313)
> at com.marsh.ste.testing.steps.DataStepUT.testChanges(DataStepUT.java:52)
> 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],
> type);
> } else if (getConvertUtils().lookup(value.getClass()) != null) {
> newValue = getConvertUtils().convert(value.toString(), type);
> } else {
> newValue = value;
> }
> cheers
> David
--
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: commons-dev-unsubscribe@jakarta.apache.org
For additional commands, e-mail: commons-dev-help@jakarta.apache.org