Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Provide explicit support for collections, maps, and arrays in ObjectUtils.nullSafeConciseToString() #30811

Closed
github-actions bot opened this issue Jul 4, 2023 · 1 comment
Assignees
Labels
in: core Issues in core modules (aop, beans, core, context, expression) type: backport An issue that is a backport of another issue to a maintenance branch type: enhancement A general enhancement
Milestone

Comments

@github-actions
Copy link

github-actions bot commented Jul 4, 2023

Backport of gh-30810

@github-actions github-actions bot added in: core Issues in core modules (aop, beans, core, context, expression) type: backport An issue that is a backport of another issue to a maintenance branch type: enhancement A general enhancement labels Jul 4, 2023
@github-actions github-actions bot added this to the 5.3.29 milestone Jul 4, 2023
@sbrannen sbrannen self-assigned this Jul 4, 2023
sbrannen added a commit that referenced this issue Jul 5, 2023
…tring()

Prior to this commit, there was no explicit support for arrays,
collections, and maps in nullSafeConciseToString(). This lead to string
representations such as the following, regardless of whether the array,
collection, or map was empty.

- char[]@1623b78d
- java.util.ImmutableCollections$List12@74fe5c40
- java.util.ImmutableCollections$MapN@10e31a9a

This commit introduces explicit support for arrays, collections, and
maps in nullSafeConciseToString(), which results in the following
empty/non-empty string representations.

- array: {} / {...}
- collection: [] / [...]
- map: {} / {...}

The reason a string representation of an array uses "{}" instead of
"[]" (like in Arrays.toString(...)) is that
ObjectUtils.nullSafeToString(<array>) already follows that convention,
and the implementation of nullSafeConciseToString() aligns with that
for the sake of consistency.

Closes gh-30811
@sbrannen
Copy link
Member

sbrannen commented Jul 5, 2023

Closed in a3907a6

@sbrannen sbrannen closed this as completed Jul 5, 2023
sbrannen added a commit that referenced this issue Sep 8, 2023
gh-30811 introduced explicit support for collections and maps in
ObjectUtils.nullSafeConciseToString() by invoking isEmpty() on a Map or
Collection to determine which concise string representation should be
used. However, this caused a regression in which an exception was
thrown if the Map or Collection was a proxy generated by
AbstractFactoryBean to support <util:set />, <util:list />, and
<util:map /> in XML configuration.

This commit addresses this set of regressions by always returning
"[...]" or "{...}" for a Collection or Map, respectively, disregarding
whether the map is empty or not.

Closes gh-31156
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
in: core Issues in core modules (aop, beans, core, context, expression) type: backport An issue that is a backport of another issue to a maintenance branch type: enhancement A general enhancement
Projects
None yet
Development

No branches or pull requests

1 participant