Do not invoke [Map|Collection].isEmpty() in nullSafeConciseToString()
gh-30810 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-31138
This commit is contained in:
@@ -1052,8 +1052,8 @@ class ObjectUtilsTests {
|
||||
void nullSafeConciseToStringForEmptyCollections() {
|
||||
List<String> list = List.of();
|
||||
Set<Integer> set = Set.of();
|
||||
assertThat(ObjectUtils.nullSafeConciseToString(list)).isEqualTo("[]");
|
||||
assertThat(ObjectUtils.nullSafeConciseToString(set)).isEqualTo("[]");
|
||||
assertThat(ObjectUtils.nullSafeConciseToString(list)).isEqualTo("[...]");
|
||||
assertThat(ObjectUtils.nullSafeConciseToString(set)).isEqualTo("[...]");
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -1066,8 +1066,8 @@ class ObjectUtilsTests {
|
||||
|
||||
@Test
|
||||
void nullSafeConciseToStringForEmptyMaps() {
|
||||
Map<String, String> map = new HashMap<String, String>();
|
||||
assertThat(ObjectUtils.nullSafeConciseToString(map)).isEqualTo("{}");
|
||||
Map<String, String> map = Map.of();
|
||||
assertThat(ObjectUtils.nullSafeConciseToString(map)).isEqualTo("{...}");
|
||||
}
|
||||
|
||||
@Test
|
||||
|
||||
Reference in New Issue
Block a user