Details
-
Bug
-
Status: Resolved
-
Minor
-
Resolution: Fixed
-
3.11
-
None
-
None
-
None
Description
The fix in LANG-1542 (git commit 1dddec8) had side effects and did not just affect json styles, but DEFAULT_STYLE, SHORT_PREFIX_STYLE, and possibly others as well.
Also, collections are now treated differently when empty:
Square brackets for empty list vs. curly brackets for non-empty lists.
Test case
new ToStringBuilder(new Object(), ToStringStyle.SHORT_PREFIX_STYLE) .append("foo0", Collections.emptyList()) .append("foo1", Collections.singleton("1")) .append("foo2", Arrays.asList("1", "2")) .build();
SHORT_PREFIX_STYLE
Result for version 3.11:
Object[foo0=[],foo1={1},foo2={1,2}]
Expected (also as-is for 3.10)
Object[foo0=[],foo1=[1],foo2=[1, 2]]
DEFAULT_STYLE
Result for version 3.11
java.lang.Object@7960847b[foo0=[],foo1={1},foo2={1,2}]
Expected (also as-is for 3.10)
java.lang.Object@7960847b[foo0=[],foo1=[1],foo2=[1, 2]]