[
https://issues.apache.org/jira/browse/LANG-1600?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=17182892#comment-17182892
]
Gary D. Gregory commented on LANG-1600:
---------------------------------------
[~amphied]
Thank you for your report.
May you please provide your use case as unit test PR on GitHub?
If you can suggest a fix in the same PR that would be great as well.
Thank you,
Gary
> ToStringBuilder behavior for collections changed with 3.11
> ----------------------------------------------------------
>
> Key: LANG-1600
> URL: https://issues.apache.org/jira/browse/LANG-1600
> Project: Commons Lang
> Issue Type: Bug
> Affects Versions: 3.11
> Environment: {code:none}
> java -version
> openjdk version "1.8.0_242"
> OpenJDK Runtime Environment (AdoptOpenJDK)(build 1.8.0_242-b08)
> OpenJDK 64-Bit Server VM (AdoptOpenJDK)(build 25.242-b08, mixed mode)
> {code}
> commons-lang3-3.10.jar via maven central
> commons-lang3-3.11.jar via maven central
> Reporter: Michael F
> Priority: Minor
>
> The fix in LANG-1542 (git commit
> [1dddec8|https://github.com/apache/commons-lang/commit/1dddec8ba867bc31233ba194f0753ea35818cbfd])
> 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.
> h3. Test case
> {code:java}
> new ToStringBuilder(new Object(), ToStringStyle.SHORT_PREFIX_STYLE)
> .append("foo0", Collections.emptyList())
> .append("foo1", Collections.singleton("1"))
> .append("foo2", Arrays.asList("1", "2"))
> .build();
> {code}
> h3. {{SHORT_PREFIX_STYLE}}
> Result for version 3.11:
> {code:none}
> Object[foo0=[],foo1={1},foo2={1,2}]
> {code}
> Expected (also as-is for 3.10)
> {code:none}
> Object[foo0=[],foo1=[1],foo2=[1, 2]]
> {code}
> h3. {{DEFAULT_STYLE}}
> Result for version 3.11
> {code:none}
> java.lang.Object@7960847b[foo0=[],foo1={1},foo2={1,2}]
> {code}
> Expected (also as-is for 3.10)
> {code:none}
> java.lang.Object@7960847b[foo0=[],foo1=[1],foo2=[1, 2]]
> {code}
--
This message was sent by Atlassian Jira
(v8.3.4#803005)