commons-issues mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Marcin Cinik (JIRA)" <j...@apache.org>
Subject [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
Date Fri, 25 Jan 2013 07:13:12 GMT

    [ https://issues.apache.org/jira/browse/BEANUTILS-387?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=13562485#comment-13562485
] 

Marcin Cinik commented on BEANUTILS-387:
----------------------------------------

'Registering a DateConverter with a default value of null is the correct solution to your
issue'.

I reckon that the default behaviour of BeanUtilsBean.copyProperties should be just to copy
properties from one bean to another bean without introducing to much hassle, especially that
both source and destination beans are of the same class. Currently that method is not working
for beans of the same class out of the box.
Shall you  justify your previous comment and clarify why the Date is exeptional in this case
please ?


                
> [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

Mime
View raw message