commons-issues mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Dominik Stadler (JIRA)" <>
Subject [jira] [Created] (LANG-1283) RecursiveToStringStyle does not handle nested Maps correctly
Date Wed, 09 Nov 2016 14:14:58 GMT
Dominik Stadler created LANG-1283:

             Summary: RecursiveToStringStyle does not handle nested Maps correctly
                 Key: LANG-1283
             Project: Commons Lang
          Issue Type: Bug
          Components: lang.builder.*
    Affects Versions: 3.4
            Reporter: Dominik Stadler

When using {{RecursiveToStringStyle}} to include all member fields of all nested objects,
it works for simple Maps, but as soon as I have Maps as values inside another Map, the contents
is not included any more, but only a Object.toString() seems to be appended for the objects

A possible fix would be to add  the following to RecursiveToStringStyle, although there might
be a better way to fix this:

        protected void appendDetail(StringBuffer buffer, String fieldName, Map<?, ?>
map) {
            appendClassName(buffer, map);
            appendIdentityHashCode(buffer, map);
            appendDetail(buffer, fieldName, map.entrySet());

See the attached unit-test for a reproducer.

Please also note that {{RecursiveToStringStyleTest}} in commons-lang seems to mostly work
on the DefaultStyle instead, see,
only one method, {{testPerson()}}, seems to actually do a real test here!

This message was sent by Atlassian JIRA

View raw message