From 198d19714ef97a8fb720f7fee913999e1ba10282 Mon Sep 17 00:00:00 2001 From: Andrew Gaul Date: Mon, 16 Apr 2012 15:09:09 -0700 Subject: [PATCH] Prefer unsynchronized StringBuilder A few instances remain due to EasyMock and Matcher. --- .../jclouds/trmk/vcloud_0_8/TerremarkClientLiveTest.java | 4 ++-- core/src/main/java/org/jclouds/crypto/Sha512Crypt.java | 8 ++++---- core/src/main/java/org/jclouds/http/HttpUtils.java | 2 +- .../java/org/jclouds/http/functions/ParseXMLWithJAXB.java | 2 +- .../src/main/java/org/jclouds/util/PasswordGenerator.java | 4 ++-- core/src/test/java/org/jclouds/http/BaseJettyTest.java | 2 +- .../java/org/jclouds/http/IntegrationTestAsyncClient.java | 2 +- .../test/java/org/jclouds/http/IntegrationTestClient.java | 2 +- .../test/java/org/jclouds/http/internal/WireLiveTest.java | 2 +- .../src/test/java/org/jclouds/http/internal/WireTest.java | 2 +- .../rest/internal/RestAnnotationProcessorTest.java | 4 ++-- .../jclouds/virtualbox/functions/IMachineToIpAddress.java | 6 +++--- .../java/org/jclouds/nirvanix/sdn/SDNAsyncClientTest.java | 2 +- 13 files changed, 21 insertions(+), 21 deletions(-) diff --git a/common/trmk/src/test/java/org/jclouds/trmk/vcloud_0_8/TerremarkClientLiveTest.java b/common/trmk/src/test/java/org/jclouds/trmk/vcloud_0_8/TerremarkClientLiveTest.java index cb33ebe12c..8cd5467115 100644 --- a/common/trmk/src/test/java/org/jclouds/trmk/vcloud_0_8/TerremarkClientLiveTest.java +++ b/common/trmk/src/test/java/org/jclouds/trmk/vcloud_0_8/TerremarkClientLiveTest.java @@ -107,7 +107,7 @@ public abstract class TerremarkClientLiveTest= 0) { result.append(itoa64.charAt((int) (v & 0x3f))); diff --git a/core/src/main/java/org/jclouds/http/HttpUtils.java b/core/src/main/java/org/jclouds/http/HttpUtils.java index 0ee0dd24cb..d9a1daf16a 100644 --- a/core/src/main/java/org/jclouds/http/HttpUtils.java +++ b/core/src/main/java/org/jclouds/http/HttpUtils.java @@ -353,7 +353,7 @@ public class HttpUtils { } public static String sortAndConcatHeadersIntoString(Multimap headers) { - StringBuffer buffer = new StringBuffer(); + StringBuilder buffer = new StringBuilder(); SortedSetMultimap sortedMap = TreeMultimap.create(); sortedMap.putAll(headers); for (Entry header : sortedMap.entries()) { diff --git a/core/src/main/java/org/jclouds/http/functions/ParseXMLWithJAXB.java b/core/src/main/java/org/jclouds/http/functions/ParseXMLWithJAXB.java index 2ed2f23c67..cbbadb2c16 100644 --- a/core/src/main/java/org/jclouds/http/functions/ParseXMLWithJAXB.java +++ b/core/src/main/java/org/jclouds/http/functions/ParseXMLWithJAXB.java @@ -72,7 +72,7 @@ public class ParseXMLWithJAXB implements Function { try { return apply(xml); } catch (Exception e) { - StringBuffer message = new StringBuffer(); + StringBuilder message = new StringBuilder(); message.append("Error parsing input"); logger.error(e, message.toString()); throw new HttpResponseException(message.toString() + "\n" + from, null, from, e); diff --git a/core/src/main/java/org/jclouds/util/PasswordGenerator.java b/core/src/main/java/org/jclouds/util/PasswordGenerator.java index a980fe0213..0de64099ec 100644 --- a/core/src/main/java/org/jclouds/util/PasswordGenerator.java +++ b/core/src/main/java/org/jclouds/util/PasswordGenerator.java @@ -51,10 +51,10 @@ public enum PasswordGenerator implements Supplier { @Override public String get() { - StringBuffer sb = new StringBuffer(); + StringBuilder sb = new StringBuilder(); for (int i = 0; i < MIN_LENGTH; i++) { sb.append(goodChar[r.nextInt(goodChar.length)]); } return sb.toString(); } -} \ No newline at end of file +} diff --git a/core/src/test/java/org/jclouds/http/BaseJettyTest.java b/core/src/test/java/org/jclouds/http/BaseJettyTest.java index efff2057df..68055e507a 100644 --- a/core/src/test/java/org/jclouds/http/BaseJettyTest.java +++ b/core/src/test/java/org/jclouds/http/BaseJettyTest.java @@ -175,7 +175,7 @@ public abstract class BaseJettyTest { client = context.getApi(); assert client != null; - assert client.newStringBuffer() != null; + assert client.newStringBuilder() != null; } private static void handlePost(HttpServletRequest request, HttpServletResponse response) throws IOException { diff --git a/core/src/test/java/org/jclouds/http/IntegrationTestAsyncClient.java b/core/src/test/java/org/jclouds/http/IntegrationTestAsyncClient.java index 694c298aab..74eec0ca6a 100644 --- a/core/src/test/java/org/jclouds/http/IntegrationTestAsyncClient.java +++ b/core/src/test/java/org/jclouds/http/IntegrationTestAsyncClient.java @@ -202,6 +202,6 @@ public interface IntegrationTestAsyncClient { } @Provides - StringBuffer newStringBuffer(); + StringBuilder newStringBuilder(); } diff --git a/core/src/test/java/org/jclouds/http/IntegrationTestClient.java b/core/src/test/java/org/jclouds/http/IntegrationTestClient.java index 8207e1055b..a1b97fba08 100644 --- a/core/src/test/java/org/jclouds/http/IntegrationTestClient.java +++ b/core/src/test/java/org/jclouds/http/IntegrationTestClient.java @@ -68,5 +68,5 @@ public interface IntegrationTestClient { String downloadAndParse(String id); @Provides - StringBuffer newStringBuffer(); + StringBuilder newStringBuilder(); } diff --git a/core/src/test/java/org/jclouds/http/internal/WireLiveTest.java b/core/src/test/java/org/jclouds/http/internal/WireLiveTest.java index b4bc891884..68db3c5465 100644 --- a/core/src/test/java/org/jclouds/http/internal/WireLiveTest.java +++ b/core/src/test/java/org/jclouds/http/internal/WireLiveTest.java @@ -68,7 +68,7 @@ public class WireLiveTest { } static class BufferLogger implements Logger { - StringBuffer buff = new StringBuffer(); + StringBuilder buff = new StringBuilder(); public void debug(String message, Object... args) { buff.append(message); diff --git a/core/src/test/java/org/jclouds/http/internal/WireTest.java b/core/src/test/java/org/jclouds/http/internal/WireTest.java index c5119fd582..d50ec08176 100644 --- a/core/src/test/java/org/jclouds/http/internal/WireTest.java +++ b/core/src/test/java/org/jclouds/http/internal/WireTest.java @@ -35,7 +35,7 @@ import org.testng.annotations.Test; public class WireTest { class BufferLogger implements Logger { - StringBuffer buff = new StringBuffer(); + StringBuilder buff = new StringBuilder(); public void debug(String message, Object... args) { buff.append(message); diff --git a/core/src/test/java/org/jclouds/rest/internal/RestAnnotationProcessorTest.java b/core/src/test/java/org/jclouds/rest/internal/RestAnnotationProcessorTest.java index f4a5b6439d..4d182e223b 100644 --- a/core/src/test/java/org/jclouds/rest/internal/RestAnnotationProcessorTest.java +++ b/core/src/test/java/org/jclouds/rest/internal/RestAnnotationProcessorTest.java @@ -2474,7 +2474,7 @@ public class RestAnnotationProcessorTest extends BaseRestClientTest { Function parser = (Function) RestAnnotationProcessor .createResponseParser(parserFactory, injector, method, request); - StringBuffer payload = new StringBuffer(XMLParser.DEFAULT_XML_HEADER); + StringBuilder payload = new StringBuilder(XMLParser.DEFAULT_XML_HEADER); payload.append("Hello World"); TestJAXBDomain domain = parser.apply(new HttpResponse(200, "ok", newStringPayload(payload.toString()))); assertEquals(domain.getElem(), "Hello World"); @@ -2492,7 +2492,7 @@ public class RestAnnotationProcessorTest extends BaseRestClientTest { Function parser = (Function) RestAnnotationProcessor .createResponseParser(parserFactory, injector, method, request); - StringBuffer payload = new StringBuffer(XMLParser.DEFAULT_XML_HEADER); + StringBuilder payload = new StringBuilder(XMLParser.DEFAULT_XML_HEADER); payload.append("Hello World"); TestJAXBDomain domain = parser.apply(new HttpResponse(200, "ok", newStringPayload(payload.toString()))); assertEquals(domain.getElem(), "Hello World"); diff --git a/labs/virtualbox/src/main/java/org/jclouds/virtualbox/functions/IMachineToIpAddress.java b/labs/virtualbox/src/main/java/org/jclouds/virtualbox/functions/IMachineToIpAddress.java index f7727e90ca..0e47da2c53 100644 --- a/labs/virtualbox/src/main/java/org/jclouds/virtualbox/functions/IMachineToIpAddress.java +++ b/labs/virtualbox/src/main/java/org/jclouds/virtualbox/functions/IMachineToIpAddress.java @@ -54,7 +54,7 @@ public class IMachineToIpAddress implements Function { String macAddress = machine.getNetworkAdapter(0l).getMACAddress(); int offset = 0, step = 2; for (int j = 1; j <= 5; j++) { - macAddress = new StringBuffer(macAddress).insert(j * step + offset, ":").toString().toLowerCase(); + macAddress = new StringBuilder(macAddress).insert(j * step + offset, ":").toString().toLowerCase(); offset++; } @@ -64,14 +64,14 @@ public class IMachineToIpAddress implements Function { IMachine hostMachine = manager.getVBox().findMachine(hostId); if (isOSX(hostMachine)) { if (simplifiedMacAddressOfClonedVM.contains("00")) - simplifiedMacAddressOfClonedVM = new StringBuffer(simplifiedMacAddressOfClonedVM).delete( + simplifiedMacAddressOfClonedVM = new StringBuilder(simplifiedMacAddressOfClonedVM).delete( simplifiedMacAddressOfClonedVM.indexOf("00"), simplifiedMacAddressOfClonedVM.indexOf("00") + 1) .toString(); if (simplifiedMacAddressOfClonedVM.contains("0")) if (simplifiedMacAddressOfClonedVM.indexOf("0") + 1 != ':' && simplifiedMacAddressOfClonedVM.indexOf("0") - 1 != ':') - simplifiedMacAddressOfClonedVM = new StringBuffer(simplifiedMacAddressOfClonedVM).delete( + simplifiedMacAddressOfClonedVM = new StringBuilder(simplifiedMacAddressOfClonedVM).delete( simplifiedMacAddressOfClonedVM.indexOf("0"), simplifiedMacAddressOfClonedVM.indexOf("0") + 1) .toString(); } diff --git a/sandbox-apis/nirvanix/src/test/java/org/jclouds/nirvanix/sdn/SDNAsyncClientTest.java b/sandbox-apis/nirvanix/src/test/java/org/jclouds/nirvanix/sdn/SDNAsyncClientTest.java index 36c294427e..0a00db3f99 100644 --- a/sandbox-apis/nirvanix/src/test/java/org/jclouds/nirvanix/sdn/SDNAsyncClientTest.java +++ b/sandbox-apis/nirvanix/src/test/java/org/jclouds/nirvanix/sdn/SDNAsyncClientTest.java @@ -85,7 +85,7 @@ public class SDNAsyncClientTest extends RestClientTest { assertRequestLineEquals(request, "POST http://uploader/Upload.ashx?output=json&destFolderPath=adriansmovies&uploadToken=token HTTP/1.1"); assertNonPayloadHeadersEqual(request, ""); - StringBuffer expects = new StringBuffer(); + StringBuilder expects = new StringBuilder(); expects.append("----JCLOUDS--\r\n"); expects.append("Content-Disposition: form-data; name=\"hello\"\r\n"); expects.append("Content-Type: text/plain\r\n\r\n");