Commons BeanUtils
  1. Commons BeanUtils
  2. BEANUTILS-387

[beanutils] copyProperties() throws a ConversionException : No value specified for 'Date' when the field is a java.util.Date with a null value

    Details

    • Type: Bug Bug
    • Status: Resolved
    • Priority: Major Major
    • Resolution: Won't Fix
    • Affects Version/s: 1.8.3
    • Fix Version/s: None
    • Component/s: Bean / Property Utils
    • Labels:
      None

      Description

      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 :

      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);
      	}
      }
      

      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.

        Issue Links

          Activity

            People

            • Assignee:
              Unassigned
              Reporter:
              Daniel Marchese
            • Votes:
              0 Vote for this issue
              Watchers:
              6 Start watching this issue

              Dates

              • Created:
                Updated:
                Resolved:

                Development