I am not sure if this is a bug or not, but it bit me and I had to modify my custom converter to work around it. Here is the issue:
1) I have a field in the source class that has a custom converter
2) The field may be null, so I set map-null to false
3) My mapping would fail because the custom converter was called with a null source object reference
My expectation was that if map-null was false and the source reference was null, the mapping was bypassed, including not calling the custom converter.
I can see where this might not be a bug, since the custom converter could map a default value when the source is null.
I worked around it by modifying my custom converter to return null when the source reference was null. Things worked as expected then, with the setter on the destination object not being called when the source field was null.
Thought I'd bring it to your attention and let you guys decide.
Log in to post a comment.