Details
-
Bug
-
Status: Resolved
-
Major
-
Resolution: Not A Problem
-
1.8.3
-
None
Description
See the following test to see the problem and its solution.
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; } } }