You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@commons.apache.org by "Markus Stahl (JIRA)" <ji...@apache.org> on 2013/05/29 16:53:20 UTC
[jira] [Commented] (BEANUTILS-387) [beanutils] copyProperties()
throws a ConversionException : No value specified for 'Date' when the
field is a java.util.Date with a null value
[ https://issues.apache.org/jira/browse/BEANUTILS-387?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=13669320#comment-13669320 ]
Markus Stahl commented on BEANUTILS-387:
----------------------------------------
I agree. It's unexpected that a null-value raises the need for a convertor, especially if the other data types seemingly just work fine with null.
In my case, the bean to be copied has been enhanced with an optional Date property in a latest release. Suddenly the copyProperties method throws ConversionExceptions.
> [beanutils] copyProperties() throws a ConversionException : No value specified for 'Date' when the field is a java.util.Date with a null value
> -----------------------------------------------------------------------------------------------------------------------------------------------
>
> Key: BEANUTILS-387
> URL: https://issues.apache.org/jira/browse/BEANUTILS-387
> Project: Commons BeanUtils
> Issue Type: Bug
> Components: Bean / Property Utils
> Affects Versions: 1.8.3
> Reporter: Daniel Marchese
>
> We have migrated the library from version 1.6.0 to 1.8.0 and the copyProperties() method fails when copying a java.util.Date attribute with a null value.
> Here is a simple testcase :
> {code}
> public class Test {
> private Date date;
>
> public Date getDate() { return date; }
> public void setDate(Date date) { this.date = date; }
> public static void main(String[] args) throws Exception {
> Test dest = new Test();
> Test source = new Test();
> BeanUtils.copyProperties(dest, source);
> }
> }
> {code}
> As a workaround, we can do this :
> ConvertUtils.register(new DateConverter(null), Date.class);
> When can also use PropertyUtils.copyProperties() because in this case no conversion is required but the impact is unknown on our big application.
> The problem is that there seems to be a regression between version 1.6.0 and 1.8.0.
--
This message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators
For more information on JIRA, see: http://www.atlassian.com/software/jira