[
https://issues.apache.org/jira/browse/LANG-1283?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=15691158#comment-15691158
]
Duncan Jones commented on LANG-1283:
------------------------------------
Thanks for the test case patch, I've applied that in commit 41bc4cd02.
> RecursiveToStringStyle does not handle nested Maps correctly
> ------------------------------------------------------------
>
> Key: LANG-1283
> URL: https://issues.apache.org/jira/browse/LANG-1283
> Project: Commons Lang
> Issue Type: Bug
> Components: lang.builder.*
> Affects Versions: 3.4
> Reporter: Dominik Stadler
> Attachments:
> LANG_1283__Make_RecursiveToStringStyleTest_actually_test_the_correct_class.patch,
> RecursiveToStringTest.java
>
>
> 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 instead.
> A possible fix would be to add the following to RecursiveToStringStyle,
> although there might be a better way to fix this:
> {code}
> @Override
> protected void appendDetail(StringBuffer buffer, String fieldName,
> Map<?, ?> map) {
> appendClassName(buffer, map);
> appendIdentityHashCode(buffer, map);
> appendDetail(buffer, fieldName, map.entrySet());
> }
> {code}
> 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
> https://github.com/apache/commons-lang/blob/master/src/test/java/org/apache/commons/lang3/builder/RecursiveToStringStyleTest.java#L38,
> only one method, {{testPerson()}}, seems to actually do a real test here!
--
This message was sent by Atlassian JIRA
(v6.3.4#6332)