#18 missing destination field readMethod throws NPE

Dozer v.4.3

When Introspector cannot find a read method for a destination property, an NPE is thrown when an attempt is made to set it. This happens even if the field is configured one-way & the inverse mapping is one-way excluded.
This is because GetterSetterPropertyDescriptor.writeDeepDestinationValue uses PropertyDescriptor.getReadMethod().getReturnType() to determine the value type to set. If no readMethod exists (as may be true for a one-way mapping), this call will throw an NPE. This value should probably be obtained from PropertyDescriptor.getWriteMethod().getParameterTypes()[0] instead. The attached patch works for me to fix this problem via this technique.


  • Corey Lohman

    Corey Lohman - 2008-08-05

    Recommended fix to GetterSetterPropertyDescriptor

  • dmitry (lv)

    dmitry (lv) - 2008-09-30
    • assigned_to: nobody --> buzdin
  • dmitry (lv)

    dmitry (lv) - 2008-10-01

    Reproduced and fixed.
    Thank you for the patch. Fixed that in less intrusive manner by checking for getter method for null first and only then taking write method.

  • dmitry (lv)

    dmitry (lv) - 2008-10-01
    • status: open --> closed-fixed
  • Corey Lohman

    Corey Lohman - 2008-10-01

    Yes, that sounds like a safer fix. Thanks for getting this one in!

  • dmitry (lv)

    dmitry (lv) - 2008-10-30
    • milestone: --> Dozer v.4.3

Log in to post a comment.

Get latest updates about Open Source Projects, Conferences and News.

Sign up for the SourceForge newsletter:

No, thanks