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

Benedikt Ritter edited comment on BEANUTILS-412 at 3/3/13 1:36 PM:
-------------------------------------------------------------------

Hi Laurent,

I've looked at the code and at your patch. Creating 0 instead of null is the 
default behavior for all Number types. As you have showed in your patch, this 
behavior can be customized by registering different converters. 

I'm closing this issue as Not A Problem, because there is a working solution.
                
      was (Author: britter):
    Hi Laurent,

I've looked at the code and at your patch. Creating 0 instead of null is the 
default behavior for all Number types. As you have showed in your patch, this 
behavior can be customized by registering different converters. 

I'm closing this issue as won't fix, because there is a working solution.
                  
> Default value is 0 instead of null for Integer properties
> ---------------------------------------------------------
>
>                 Key: BEANUTILS-412
>                 URL: https://issues.apache.org/jira/browse/BEANUTILS-412
>             Project: Commons BeanUtils
>          Issue Type: Bug
>          Components: Locale BeanUtils / Converters
>    Affects Versions: 1.8.3
>            Reporter: Laurent Kloetzer
>            Assignee: Benedikt Ritter
>             Fix For: 1.8.4
>
>
> See the following test to see the problem and its solution.
> {code}
> public class Test {
>       /**
>        * @param args
>        * @throws InvocationTargetException
>        * @throws IllegalAccessException
>        */
>       public static void main(String[] args) throws IllegalAccessException, 
> InvocationTargetException {
>               test(false);
>               test(true);
>       }
>       protected static void test(boolean withFix) throws 
> IllegalAccessException, InvocationTargetException {
>               Thing t1 = new Thing();
>               t1.valInt = 1;
>               t1.valInteger = 2;
>               Thing t2 = new Thing();
>               t2.valInt = 0;
>               t2.valInteger = null;
>               Thing t3 = new Thing();
>               Thing t4 = new Thing();
>               System.out.println(t2);
>               System.out.println(t1);
>               if (withFix) {
>                       IntegerConverter ic = new IntegerConverter(null);
>                       
> BeanUtilsBean.getInstance().getConvertUtils().register(ic, Integer.class);
>               }
>               BeanUtilsBean.getInstance().copyProperties(t3, t1);
>               BeanUtilsBean.getInstance().copyProperties(t4, t2);
>               System.out.println(t4);
>               System.out.println(t3);
>       }
>       public static class Thing {
>               private int valInt;
>               private Integer valInteger;
>               @Override
>               public String toString() {
>                       return ToStringBuilder.reflectionToString(this);
>               }
>               public int getValInt() {
>                       return valInt;
>               }
>               public void setValInt(int valInt) {
>                       this.valInt = valInt;
>               }
>               public Integer getValInteger() {
>                       return valInteger;
>               }
>               public void setValInteger(Integer valInteger) {
>                       this.valInteger = valInteger;
>               }
>       }
> }
> {code}

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

Reply via email to