Use StringJoiner where possible to simplify String joining

Closes gh-23237
This commit is contained in:
Сергей Цыпанов
2019-07-07 17:19:01 +03:00
committed by Sam Brannen
parent 8f5b2b2231
commit 9f81ffa5ae
4 changed files with 19 additions and 26 deletions

View File

@@ -18,6 +18,7 @@ package org.springframework.beans;
import java.io.PrintStream;
import java.io.PrintWriter;
import java.util.StringJoiner;
import org.springframework.lang.Nullable;
import org.springframework.util.Assert;
@@ -85,12 +86,9 @@ public class PropertyBatchUpdateException extends BeansException {
@Override
public String getMessage() {
StringBuilder sb = new StringBuilder("Failed properties: ");
for (int i = 0; i < this.propertyAccessExceptions.length; i++) {
sb.append(this.propertyAccessExceptions[i].getMessage());
if (i < this.propertyAccessExceptions.length - 1) {
sb.append("; ");
}
StringJoiner sb = new StringJoiner("; ", "Failed properties: ", "");
for (PropertyAccessException exception : this.propertyAccessExceptions) {
sb.add(exception.getMessage());
}
return sb.toString();
}