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

Introduce ObjectUtils.nullSafeConciseToString() #30287

Closed
github-actions bot opened this issue Apr 4, 2023 · 2 comments
Closed

Introduce ObjectUtils.nullSafeConciseToString() #30287

github-actions bot opened this issue Apr 4, 2023 · 2 comments
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 Apr 4, 2023

Backport of gh-30286

@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 Apr 4, 2023
@github-actions github-actions bot added this to the 5.3.27 milestone Apr 4, 2023
@sbrannen sbrannen self-assigned this Apr 4, 2023
@sbrannen sbrannen changed the title Introduce nullSafeSimpleToString(Object) in ObjectUtils Introduce nullSafeConciseToString(Object) in ObjectUtils Apr 5, 2023
@sbrannen sbrannen changed the title Introduce nullSafeConciseToString(Object) in ObjectUtils Introduce ObjectUtils.nullSafeConciseToString() Apr 5, 2023
@sbrannen
Copy link
Member

sbrannen commented Apr 5, 2023

Closed in 91c58af

@sbrannen sbrannen closed this as completed Apr 5, 2023
@asjp1970
Copy link

asjp1970 commented Jul 3, 2023

Hi,
This new method doesn't work for empty collections. We were using 5.3.24 before, where nullSafeToString was used instead, and in case, for instance of an empty ArrayList, it returned the string "[]" as representation of the empty collection (because it ended up calling the proper toString method in java.util.AbstractCollection).

Now this method decides that cannot handle emtpy collections and returns:

return type.getTypeName() + "@" + getIdentityHexString(obj);

thus ignoring the possible toString implementation of anything not matching the if's in lines 947 and 954.

I will issue a ticket.

Probably we are missing unit tests here... I know that they can be in the grey area of testing the obvious, but in this case the fault with empty collections would not have slept through.

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

2 participants