8274898: Cleanup usages of StringBuffer in jdk tools modules

Reviewed-by: sspitsyn, lmesnik
This commit is contained in:
Andrey Turbanov 2021-12-15 19:28:58 +00:00 committed by Serguei Spitsyn
parent 7517c85da3
commit 04dbdd36dd
3 changed files with 8 additions and 8 deletions

View file

@ -834,9 +834,9 @@ public class Main {
} }
// Only used when -verbose provided // Only used when -verbose provided
StringBuffer sb = null; StringBuilder sb = null;
if (verbose != null) { if (verbose != null) {
sb = new StringBuffer(); sb = new StringBuilder();
boolean inManifest = boolean inManifest =
((man.getAttributes(name) != null) || ((man.getAttributes(name) != null) ||
(man.getAttributes("./"+name) != null) || (man.getAttributes("./"+name) != null) ||

View file

@ -108,7 +108,7 @@ public class Log {
public void verbose(List<String> strings, public void verbose(List<String> strings,
List<String> output, int returnCode, long pid) { List<String> output, int returnCode, long pid) {
if (verbose) { if (verbose) {
StringBuffer sb = new StringBuffer(); StringBuilder sb = new StringBuilder();
sb.append("Command [PID: "); sb.append("Command [PID: ");
sb.append(pid); sb.append(pid);
sb.append("]:\n "); sb.append("]:\n ");
@ -116,13 +116,13 @@ public class Log {
for (String s : strings) { for (String s : strings) {
sb.append(" " + s); sb.append(" " + s);
} }
verbose(new String(sb)); verbose(sb.toString());
if (output != null && !output.isEmpty()) { if (output != null && !output.isEmpty()) {
sb = new StringBuffer("Output:"); sb = new StringBuilder("Output:");
for (String s : output) { for (String s : output) {
sb.append("\n " + s); sb.append("\n " + s);
} }
verbose(new String(sb)); verbose(sb.toString());
} }
verbose("Returned: " + returnCode + "\n"); verbose("Returned: " + returnCode + "\n");
} }

View file

@ -1,5 +1,5 @@
/* /*
* Copyright (c) 2016, 2020, Oracle and/or its affiliates. All rights reserved. * Copyright (c) 2016, 2021, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
* *
* This code is free software; you can redistribute it and/or modify it * This code is free software; you can redistribute it and/or modify it
@ -372,7 +372,7 @@ class Feedback {
return ""; return "";
} }
Matcher m = FIELD_PATTERN.matcher(format); Matcher m = FIELD_PATTERN.matcher(format);
StringBuffer sb = new StringBuffer(format.length()); StringBuilder sb = new StringBuilder(format.length());
while (m.find()) { while (m.find()) {
String fieldName = m.group(1); String fieldName = m.group(1);
String sub = format(fieldName, selector); String sub = format(fieldName, selector);