#276 Mixed-type values in Map incorrectly all converted to String

Dozer v5.3.0

Situation: A bean with a Map<String,Object>. The Map contains objects of various types, including an ArrayList.
Result: All values mapped after the ArrayList has been mapped are incorrectly converted to java.lang.String
Expected Result: All values are mapped 1:1 to their original type, including the ArrayList.

Analysis: The ArrayList object in the Map causes mapCollection() to set a destination type hint into the FieldMap. It uses java.lang.String (taken from the Map's generic type of the key?!?!) as the hint. The same FieldMap is then used for the rest of the entries in the Map. All the entries are converted to Strings.

Test case attached.


  • Mike R. Haller

    Mike R. Haller - 2010-09-01

    JUnit test case for reproducing the problem with current Dozer 5.2.2 release

  • dmitry (lv)

    dmitry (lv) - 2010-09-02

    Thank you for exceptionally good test case, this helped a lot!
    This was solved by cloning field map instead of replacing global instance.

  • dmitry (lv)

    dmitry (lv) - 2010-09-02
    • milestone: 1129554 --> Dozer v5.3.0
    • assigned_to: nobody --> buzdin
    • status: open --> closed-fixed

Log in to post a comment.

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

Sign up for the SourceForge newsletter:

No, thanks