BATCH-2407 Use StringBuilder instead of StringBuffer
With Java 1.5 StringBuilder is preferred over StringBuffer for single threaded access as is has less overhead. This is evidenced by the class comment of StringBuffer and Effective Java 2nd Edition Item 67: Avoid excessive synchronization. > The StringBuilder class should generally be used in preference to > this one, as it supports all of the same operations but it is faster, > as it performs no synchronization. - replace StringBuffer with StringBuilder where possible Issue: BATCH-2407
This commit is contained in:
committed by
Michael Minella
parent
7092102748
commit
dcc9da8273
@@ -157,9 +157,9 @@ public class JobParametersTests {
|
||||
public void testToStringOrder() {
|
||||
|
||||
Map<String, JobParameter> props = parameters.getParameters();
|
||||
StringBuffer stringBuilder = new StringBuffer();
|
||||
StringBuilder stringBuilder = new StringBuilder();
|
||||
for (Entry<String, JobParameter> entry : props.entrySet()) {
|
||||
stringBuilder.append(entry.toString() + ";");
|
||||
stringBuilder.append(entry.toString()).append(";");
|
||||
}
|
||||
|
||||
String string1 = stringBuilder.toString();
|
||||
@@ -177,9 +177,9 @@ public class JobParametersTests {
|
||||
JobParameters testProps = new JobParameters(parameterMap);
|
||||
|
||||
props = testProps.getParameters();
|
||||
stringBuilder = new StringBuffer();
|
||||
stringBuilder = new StringBuilder();
|
||||
for (Entry<String, JobParameter> entry : props.entrySet()) {
|
||||
stringBuilder.append(entry.toString() + ";");
|
||||
stringBuilder.append(entry.toString()).append(";");
|
||||
}
|
||||
String string2 = stringBuilder.toString();
|
||||
|
||||
|
||||
@@ -79,7 +79,7 @@ public class JdbcJobInstanceDaoTests extends AbstractJobInstanceDaoTests {
|
||||
public void testHexing() throws Exception {
|
||||
MessageDigest digest = MessageDigest.getInstance("MD5");
|
||||
byte[] bytes = digest.digest("f78spx".getBytes("UTF-8"));
|
||||
StringBuffer output = new StringBuffer();
|
||||
StringBuilder output = new StringBuilder();
|
||||
for (byte bite : bytes) {
|
||||
output.append(String.format("%02x", bite));
|
||||
}
|
||||
|
||||
@@ -49,7 +49,7 @@ public class JdbcStepExecutionDaoTests extends AbstractStepExecutionDaoTests {
|
||||
@Test
|
||||
public void testTruncateExitDescription() {
|
||||
|
||||
StringBuffer sb = new StringBuffer();
|
||||
StringBuilder sb = new StringBuilder();
|
||||
for (int i = 0; i < 100; i++) {
|
||||
sb.append("too long exit description");
|
||||
}
|
||||
|
||||
@@ -135,10 +135,10 @@ public class DataSourceInitializer implements InitializingBean {
|
||||
}
|
||||
|
||||
private String stripComments(List<String> list) {
|
||||
StringBuffer buffer = new StringBuffer();
|
||||
StringBuilder buffer = new StringBuilder();
|
||||
for (String line : list) {
|
||||
if (!line.startsWith("//") && !line.startsWith("--")) {
|
||||
buffer.append(line + "\n");
|
||||
buffer.append(line).append("\n");
|
||||
}
|
||||
}
|
||||
return buffer.toString();
|
||||
|
||||
Reference in New Issue
Block a user