You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
changed the title [-]Introduce `nullSafeSimpleToString(Object)` in `ObjectUtils`[/-][+]Introduce `nullSafeConciseToString(Object)` in `ObjectUtils`[/+]on Apr 5, 2023
changed the title [-]Introduce `nullSafeConciseToString(Object)` in `ObjectUtils`[/-][+]Introduce `ObjectUtils.nullSafeConciseToString()`[/+]on Apr 5, 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:
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.
Activity
[-]Introduce `nullSafeSimpleToString(Object)` in `ObjectUtils`[/-][+]Introduce `nullSafeConciseToString(Object)` in `ObjectUtils`[/+][-]Introduce `nullSafeConciseToString(Object)` in `ObjectUtils`[/-][+]Introduce `ObjectUtils.nullSafeConciseToString()`[/+]sbrannen commentedon Apr 5, 2023
Closed in 91c58af
asjp1970 commentedon 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.