commons-issues mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Tj Zecca (JIRA)" <j...@apache.org>
Subject [jira] Created: (BEANUTILS-317) BeanUtils.setProperty does not seem to be able to set a null value on a java.lang.Integer
Date Tue, 03 Jun 2008 22:52:45 GMT
BeanUtils.setProperty does not seem to be able to set a null value on a java.lang.Integer
-----------------------------------------------------------------------------------------

                 Key: BEANUTILS-317
                 URL: https://issues.apache.org/jira/browse/BEANUTILS-317
             Project: Commons BeanUtils
          Issue Type: Bug
          Components: Bean / Property Utils
    Affects Versions: 1.8.0-BETA, 1.7.0, 1.6.1, 1.6
         Environment: Java 1.6
            Reporter: Tj Zecca


I get the following unexpected results:

INITIAL STATE: null
AFTER SETTER: 5
AFTER BeanUtils.setProperty: 0


Using the following code:

public static void main(String[] args) {
    SimpleBean bean = new SimpleBean();
    System.out.println("INITIAL STATE: " + bean.getNum());

    bean.setNum(new Integer(5));
    System.out.println("AFTER SETTER: " + bean.getNum());

    try {
        BeanUtils.setProperty(bean, "num", null);
        System.out.println("AFTER BeanUtils.setProperty: " + bean.getNum());
    } catch (Exception e) {
        e.printStackTrace();
    }
}

public class SimpleBean {
    private Integer num;

    public Integer getNum() {
        return this.num;
    }

    public void setNum(Integer num) {
        this.num = num;
    }
}

PS. I have also tested with the Boolean primitive wrapper and it does not set null either.


-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.


Mime
View raw message