when we copy some property ,for example :
private Integer status;//source
private int status;//target
if the source property is null, then throw new FatalBeanException( "Could not copy property '" + targetPd.getName() + "' from source to target", ex);
to fix it , maybe need to skip the null value
Comment From: importsource
in my case, when i want to transfer one entity to thrift entity,then throw this exception
Comment From: sbrannen
Actually, a null value is permissible if the target property is not a primitive. So, I think it would be inappropriate to simply skip all null values. Furthermore, doing so would be a breaking change.
However, for the use case you supplied, the source is an Integer (which may be null); whereas, the target is an int which can never be null. Thus, for such use cases, I suppose we have two options:
- Leave it as-is, throwing a
FatalBeanExceptionto indicate the failure. - Skip
nullvalues only for primitive target types, potentially logging aDEBUGstatement.
@jhoeller, what are your thoughts on the matter?
Comment From: importsource
For my case, now I have to copy the BeanUtils file and then override it in my local project. So, I propose to skip the null value for the primitive target types.