Fix collectionToDelimitedString failure for null elements.
Prior to this commit, calling `StringUtils#collectionToDelimitedString` would fail with an NPE if the collection contains null elements. This commit ensures that null elements are converted as `"null"` in the resulting String without failure. See gh-27419
This commit is contained in:
parent
008aa48d5c
commit
0d6cc12274
|
@ -1301,7 +1301,7 @@ public abstract class StringUtils {
|
|||
|
||||
int totalLength = coll.size() * (prefix.length() + suffix.length()) + (coll.size() - 1) * delim.length();
|
||||
for (Object element : coll) {
|
||||
totalLength += element.toString().length();
|
||||
totalLength += String.valueOf(element).length();
|
||||
}
|
||||
|
||||
StringBuilder sb = new StringBuilder(totalLength);
|
||||
|
|
Loading…
Reference in New Issue