8298090: Use String.join() instead of manual loop in DescriptorSupport.toString

Reviewed-by: stsypanov, sspitsyn, lmesnik
This commit is contained in:
Andrey Turbanov 2022-12-12 07:36:34 +00:00
parent a37de62d9d
commit d646e32b7a

View File

@ -1234,14 +1234,13 @@ public class DescriptorSupport
MODELMBEAN_LOGGER.log(Level.TRACE, "Entry");
}
String respStr = "";
String[] fields = getFields();
if ((fields == null) || (fields.length == 0)) {
if (MODELMBEAN_LOGGER.isLoggable(Level.TRACE)) {
MODELMBEAN_LOGGER.log(Level.TRACE, "Empty Descriptor");
}
return respStr;
return "";
}
if (MODELMBEAN_LOGGER.isLoggable(Level.TRACE)) {
@ -1249,13 +1248,7 @@ public class DescriptorSupport
"Printing " + fields.length + " fields");
}
for (int i=0; i < fields.length; i++) {
if (i == (fields.length - 1)) {
respStr = respStr.concat(fields[i]);
} else {
respStr = respStr.concat(fields[i] + ", ");
}
}
String respStr = String.join(", ", fields);
if (MODELMBEAN_LOGGER.isLoggable(Level.TRACE)) {
MODELMBEAN_LOGGER.log(Level.TRACE, "Exit returning " + respStr);