Skip to content

Introduce ObjectUtils.nullSafeConciseToString() #30287

Closed

Description

@github-actions

Backport of gh-30286

Activity

  1. added
    in: coreIssues in core modules (aop, beans, core, context, expression)
    type: backportAn issue that is a backport of another issue to a maintenance branch
    on Apr 4, 2023
  2. added this to the 5.3.27 milestone on Apr 4, 2023
  3. self-assigned this
    on Apr 4, 2023
  4. changed the title [-]Introduce `nullSafeSimpleToString(Object)` in `ObjectUtils`[/-] [+]Introduce `nullSafeConciseToString(Object)` in `ObjectUtils`[/+] on Apr 5, 2023
  5. changed the title [-]Introduce `nullSafeConciseToString(Object)` in `ObjectUtils`[/-] [+]Introduce `ObjectUtils.nullSafeConciseToString()`[/+] on Apr 5, 2023
  6. sbrannen commented on Apr 5, 2023

    @sbrannen
    Member

    Closed in 91c58af

  7. asjp1970 commented on Jul 3, 2023

    @asjp1970

    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

Metadata

Metadata

Assignees

Labels

in: coreIssues in core modules (aop, beans, core, context, expression)type: backportAn issue that is a backport of another issue to a maintenance branchtype: enhancementA general enhancement

Type

No type

Projects

No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions