Details
-
Bug
-
Status: Open
-
Major
-
Resolution: Unresolved
-
3.4
-
None
-
None
-
Patch
Description
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:
@Override 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 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!