From af692bcacd630bf9799bcea343f10214e9b6ecd7 Mon Sep 17 00:00:00 2001 From: Olivier Lamy Date: Wed, 8 Aug 2012 22:10:11 +0000 Subject: [PATCH] use StringBuilder rather than StringBuffer git-svn-id: https://svn.apache.org/repos/asf/archiva/trunk@1370992 13f79535-47bb-0310-9956-ffa450edef68 --- .../org/apache/archiva/common/utils/DateUtil.java | 4 ++-- ...oxyConnectorConfigurationOrderComparatorTest.java | 2 +- .../org/apache/archiva/model/ArchivaArtifact.java | 4 ++-- .../src/main/java/org/apache/archiva/model/Keys.java | 6 +++--- .../archiva-model/src/main/mdo/archiva-base.xml | 8 ++++---- .../apache/archiva/policies/ChecksumPolicyTest.java | 2 +- .../org/apache/archiva/proxy/ProxyConnector.java | 2 +- .../apache/archiva/proxy/AbstractProxyTestCase.java | 2 +- .../archiva/repository/content/FilenameParser.java | 2 +- .../content/ManagedLegacyRepositoryContentTest.java | 2 +- .../repository/scanner/RepositoryScanStatistics.java | 2 +- .../archiva/xml/LatinEntityResolutionReader.java | 10 +++++----- .../archiva/xml/LatinEntityResolutionReaderTest.java | 12 ++++++------ .../java/org/apache/archiva/xml/XMLWriterTest.java | 2 +- .../archiva-webapp-js/src/main/webapp/js/text.js | 12 ++++++------ .../archiva/web/action/AbstractWebworkTestCase.java | 4 ++-- .../proxy/SortProxyConnectorsActionTest.java | 2 +- ...ractRepositoryServletProxiedMetadataTestCase.java | 6 +++--- 18 files changed, 42 insertions(+), 42 deletions(-) diff --git a/archiva-modules/archiva-base/archiva-common/src/main/java/org/apache/archiva/common/utils/DateUtil.java b/archiva-modules/archiva-base/archiva-common/src/main/java/org/apache/archiva/common/utils/DateUtil.java index 79d2bdc8e..01032d825 100644 --- a/archiva-modules/archiva-base/archiva-common/src/main/java/org/apache/archiva/common/utils/DateUtil.java +++ b/archiva-modules/archiva-base/archiva-common/src/main/java/org/apache/archiva/common/utils/DateUtil.java @@ -97,7 +97,7 @@ public class DateUtil --leftDays; } - StringBuffer interval = new StringBuffer(); + StringBuilder interval = new StringBuilder(); appendInterval( interval, leftDays, "Day" ); appendInterval( interval, leftHours, "Hour" ); @@ -108,7 +108,7 @@ public class DateUtil return interval.toString(); } - private static void appendInterval( StringBuffer interval, int count, String type ) + private static void appendInterval( StringBuilder interval, int count, String type ) { if ( count > 0 ) { diff --git a/archiva-modules/archiva-base/archiva-configuration/src/test/java/org/apache/archiva/configuration/functors/ProxyConnectorConfigurationOrderComparatorTest.java b/archiva-modules/archiva-base/archiva-configuration/src/test/java/org/apache/archiva/configuration/functors/ProxyConnectorConfigurationOrderComparatorTest.java index 7f610a7a0..49fc0a063 100644 --- a/archiva-modules/archiva-base/archiva-configuration/src/test/java/org/apache/archiva/configuration/functors/ProxyConnectorConfigurationOrderComparatorTest.java +++ b/archiva-modules/archiva-base/archiva-configuration/src/test/java/org/apache/archiva/configuration/functors/ProxyConnectorConfigurationOrderComparatorTest.java @@ -101,7 +101,7 @@ public class ProxyConnectorConfigurationOrderComparatorTest if ( orderFailedAt >= 0 ) { - StringBuffer msg = new StringBuffer(); + StringBuilder msg = new StringBuilder(); msg.append( "Failed expected order of the proxies <" ); msg.append( StringUtils.join( ids, ", " ) ); diff --git a/archiva-modules/archiva-base/archiva-model/src/main/java/org/apache/archiva/model/ArchivaArtifact.java b/archiva-modules/archiva-base/archiva-model/src/main/java/org/apache/archiva/model/ArchivaArtifact.java index feef28b7d..00a797236 100644 --- a/archiva-modules/archiva-base/archiva-model/src/main/java/org/apache/archiva/model/ArchivaArtifact.java +++ b/archiva-modules/archiva-base/archiva-model/src/main/java/org/apache/archiva/model/ArchivaArtifact.java @@ -197,7 +197,7 @@ public class ArchivaArtifact @Override public String toString() { - StringBuffer sb = new StringBuffer(); + StringBuilder sb = new StringBuilder(); if ( model.getGroupId() != null ) { sb.append( model.getGroupId() ); @@ -213,7 +213,7 @@ public class ArchivaArtifact return sb.toString(); } - private void appendArtifactTypeClassifierString( StringBuffer sb ) + private void appendArtifactTypeClassifierString( StringBuilder sb ) { sb.append( model.getArtifactId() ); sb.append( ":" ); diff --git a/archiva-modules/archiva-base/archiva-model/src/main/java/org/apache/archiva/model/Keys.java b/archiva-modules/archiva-base/archiva-model/src/main/java/org/apache/archiva/model/Keys.java index 1b2057efd..8be312a30 100644 --- a/archiva-modules/archiva-base/archiva-model/src/main/java/org/apache/archiva/model/Keys.java +++ b/archiva-modules/archiva-base/archiva-model/src/main/java/org/apache/archiva/model/Keys.java @@ -30,7 +30,7 @@ public class Keys { public static String toKey( String groupId, String artifactId, String version, String classifier, String type ) { - StringBuffer key = new StringBuffer(); + StringBuilder key = new StringBuilder(); key.append( groupId ).append( ":" ); key.append( artifactId ).append( ":" ); @@ -48,7 +48,7 @@ public class Keys public static String toKey( ProjectReference ref ) { - StringBuffer key = new StringBuffer(); + StringBuilder key = new StringBuilder(); key.append( ref.getGroupId() ).append( ":" ); key.append( ref.getArtifactId() ); @@ -58,7 +58,7 @@ public class Keys public static String toKey( String groupId, String artifactId, String version ) { - StringBuffer key = new StringBuffer(); + StringBuilder key = new StringBuilder(); key.append( groupId ).append( ":" ); key.append( artifactId ).append( ":" ); diff --git a/archiva-modules/archiva-base/archiva-model/src/main/mdo/archiva-base.xml b/archiva-modules/archiva-base/archiva-model/src/main/mdo/archiva-base.xml index b949c2e83..71bcd79cc 100644 --- a/archiva-modules/archiva-base/archiva-model/src/main/mdo/archiva-base.xml +++ b/archiva-modules/archiva-base/archiva-model/src/main/mdo/archiva-base.xml @@ -504,7 +504,7 @@ public static String toKey( ProjectReference reference ) { - StringBuffer key = new StringBuffer(); + StringBuilder key = new StringBuilder(); key.append( defaultString( reference.getGroupId() ) ).append( ":" ); key.append( defaultString( reference.getArtifactId() ) ); @@ -574,7 +574,7 @@ public static String toKey( VersionedReference reference ) { - StringBuffer key = new StringBuffer(); + StringBuilder key = new StringBuilder(); key.append( defaultString( reference.getGroupId() ) ).append( ":" ); key.append( defaultString( reference.getArtifactId() ) ).append( ":" ); @@ -664,7 +664,7 @@ public static String toKey( ArtifactReference artifactReference ) { - StringBuffer key = new StringBuffer(); + StringBuilder key = new StringBuilder(); key.append( defaultString( artifactReference.getGroupId() ) ).append( ":" ); key.append( defaultString( artifactReference.getArtifactId() ) ).append( ":" ); @@ -677,7 +677,7 @@ public static String toVersionlessKey( ArtifactReference artifactReference ) { - StringBuffer key = new StringBuffer(); + StringBuilder key = new StringBuilder(); key.append( defaultString( artifactReference.getGroupId() ) ).append( ":" ); key.append( defaultString( artifactReference.getArtifactId() ) ).append( ":" ); diff --git a/archiva-modules/archiva-base/archiva-policies/src/test/java/org/apache/archiva/policies/ChecksumPolicyTest.java b/archiva-modules/archiva-base/archiva-policies/src/test/java/org/apache/archiva/policies/ChecksumPolicyTest.java index 178443509..0ecce463a 100644 --- a/archiva-modules/archiva-base/archiva-policies/src/test/java/org/apache/archiva/policies/ChecksumPolicyTest.java +++ b/archiva-modules/archiva-base/archiva-policies/src/test/java/org/apache/archiva/policies/ChecksumPolicyTest.java @@ -298,7 +298,7 @@ public class ChecksumPolicyTest private String createMessage( String settingType, String md5State, String sha1State ) { - StringBuffer msg = new StringBuffer(); + StringBuilder msg = new StringBuilder(); msg.append( "Expected result of ChecksumPolicy.apply(" ); msg.append( settingType.toUpperCase() ); msg.append( ") when working with " ); diff --git a/archiva-modules/archiva-base/archiva-proxy/src/main/java/org/apache/archiva/proxy/ProxyConnector.java b/archiva-modules/archiva-base/archiva-proxy/src/main/java/org/apache/archiva/proxy/ProxyConnector.java index 8bf53b6fd..2a11dd6ee 100644 --- a/archiva-modules/archiva-base/archiva-proxy/src/main/java/org/apache/archiva/proxy/ProxyConnector.java +++ b/archiva-modules/archiva-base/archiva-proxy/src/main/java/org/apache/archiva/proxy/ProxyConnector.java @@ -124,7 +124,7 @@ public class ProxyConnector @Override public String toString() { - StringBuffer sb = new StringBuffer(); + StringBuilder sb = new StringBuilder(); sb.append( "ProxyConnector[\n" ); sb.append( " source: [managed] " ).append( this.sourceRepository.getRepoRoot() ).append( "\n" ); diff --git a/archiva-modules/archiva-base/archiva-proxy/src/test/java/org/apache/archiva/proxy/AbstractProxyTestCase.java b/archiva-modules/archiva-base/archiva-proxy/src/test/java/org/apache/archiva/proxy/AbstractProxyTestCase.java index d516309b3..a6d210dab 100644 --- a/archiva-modules/archiva-base/archiva-proxy/src/test/java/org/apache/archiva/proxy/AbstractProxyTestCase.java +++ b/archiva-modules/archiva-base/archiva-proxy/src/test/java/org/apache/archiva/proxy/AbstractProxyTestCase.java @@ -353,7 +353,7 @@ public abstract class AbstractProxyTestCase org.apache.commons.io.FileUtils.listFiles( workingDir, new String[]{ "tmp" }, false ); if ( !tmpFiles.isEmpty() ) { - StringBuffer emsg = new StringBuffer(); + StringBuilder emsg = new StringBuilder(); emsg.append( "Found Temp Files in dir: " ).append( workingDir.getPath() ); for ( File tfile : tmpFiles ) { diff --git a/archiva-modules/archiva-base/archiva-repository-layer/src/main/java/org/apache/archiva/repository/content/FilenameParser.java b/archiva-modules/archiva-base/archiva-repository-layer/src/main/java/org/apache/archiva/repository/content/FilenameParser.java index a86308fe9..39ec39d78 100644 --- a/archiva-modules/archiva-base/archiva-repository-layer/src/main/java/org/apache/archiva/repository/content/FilenameParser.java +++ b/archiva-modules/archiva-base/archiva-repository-layer/src/main/java/org/apache/archiva/repository/content/FilenameParser.java @@ -187,7 +187,7 @@ public class FilenameParser { boolean done = false; - StringBuffer ver = new StringBuffer(); + StringBuilder ver = new StringBuilder(); // Any text upto the end of a special case is considered non-version. Matcher specialMat = mavenPluginPattern.matcher( name ); diff --git a/archiva-modules/archiva-base/archiva-repository-layer/src/test/java/org/apache/archiva/repository/content/ManagedLegacyRepositoryContentTest.java b/archiva-modules/archiva-base/archiva-repository-layer/src/test/java/org/apache/archiva/repository/content/ManagedLegacyRepositoryContentTest.java index 3d3683a3e..2d5cae1be 100644 --- a/archiva-modules/archiva-base/archiva-repository-layer/src/test/java/org/apache/archiva/repository/content/ManagedLegacyRepositoryContentTest.java +++ b/archiva-modules/archiva-base/archiva-repository-layer/src/test/java/org/apache/archiva/repository/content/ManagedLegacyRepositoryContentTest.java @@ -150,7 +150,7 @@ public class ManagedLegacyRepositoryContentTest "org.apache.maven/distributions/testing-1.0.tar.gz", "org.apache.maven/distributions/testing-1.0.zip", "org.apache.maven/javadoc.jars/testing-1.0-javadoc.jar" }; - StringBuffer relatedDebugString = new StringBuffer(); + StringBuilder relatedDebugString = new StringBuilder(); relatedDebugString.append( "[" ); for ( ArtifactReference ref : related ) { diff --git a/archiva-modules/archiva-base/archiva-repository-scanner/src/main/java/org/apache/archiva/repository/scanner/RepositoryScanStatistics.java b/archiva-modules/archiva-base/archiva-repository-scanner/src/main/java/org/apache/archiva/repository/scanner/RepositoryScanStatistics.java index 6f5f1a111..d5b862b82 100644 --- a/archiva-modules/archiva-base/archiva-repository-scanner/src/main/java/org/apache/archiva/repository/scanner/RepositoryScanStatistics.java +++ b/archiva-modules/archiva-base/archiva-repository-scanner/src/main/java/org/apache/archiva/repository/scanner/RepositoryScanStatistics.java @@ -119,7 +119,7 @@ public class RepositoryScanStatistics public String toDump( ManagedRepository repo ) { - StringBuffer buf = new StringBuffer(); + StringBuilder buf = new StringBuilder(); buf.append( "\n.\\ Scan of " ).append( this.getRepositoryId() ); buf.append( " \\.__________________________________________" ); diff --git a/archiva-modules/archiva-base/archiva-xml-tools/src/main/java/org/apache/archiva/xml/LatinEntityResolutionReader.java b/archiva-modules/archiva-base/archiva-xml-tools/src/main/java/org/apache/archiva/xml/LatinEntityResolutionReader.java index 388b661dc..17313d642 100644 --- a/archiva-modules/archiva-base/archiva-xml-tools/src/main/java/org/apache/archiva/xml/LatinEntityResolutionReader.java +++ b/archiva-modules/archiva-base/archiva-xml-tools/src/main/java/org/apache/archiva/xml/LatinEntityResolutionReader.java @@ -96,7 +96,7 @@ public class LatinEntityResolutionReader } } - StringBuffer sbuf = getExpandedBuffer( current_requested_length ); + StringBuilder sbuf = getExpandedBuffer( current_requested_length ); // Have we reached the end of the buffer? if ( sbuf == null ) @@ -127,10 +127,10 @@ public class LatinEntityResolutionReader return ( current_requested_offset - offset ) + tmp_length; } - private StringBuffer getExpandedBuffer( int minimum_length ) + private StringBuilder getExpandedBuffer( int minimum_length ) throws IOException { - StringBuffer buf = null; + StringBuilder buf = null; String line = this.originalReader.readLine(); boolean done = ( line == null ); @@ -138,7 +138,7 @@ public class LatinEntityResolutionReader { if ( buf == null ) { - buf = new StringBuffer(); + buf = new StringBuilder(); } buf.append( expandLine( line ) ); @@ -165,7 +165,7 @@ public class LatinEntityResolutionReader private String expandLine( String line ) { - StringBuffer ret = new StringBuffer(); + StringBuilder ret = new StringBuilder(); int offset = 0; String entity; diff --git a/archiva-modules/archiva-base/archiva-xml-tools/src/test/java/org/apache/archiva/xml/LatinEntityResolutionReaderTest.java b/archiva-modules/archiva-base/archiva-xml-tools/src/test/java/org/apache/archiva/xml/LatinEntityResolutionReaderTest.java index 20ada7d81..137018c9f 100644 --- a/archiva-modules/archiva-base/archiva-xml-tools/src/test/java/org/apache/archiva/xml/LatinEntityResolutionReaderTest.java +++ b/archiva-modules/archiva-base/archiva-xml-tools/src/test/java/org/apache/archiva/xml/LatinEntityResolutionReaderTest.java @@ -83,7 +83,7 @@ public class LatinEntityResolutionReaderTest File exampleFile = getExampleXml( examplePath ); FileReader fileReader = new FileReader( exampleFile ); BufferedReader lineReader = new BufferedReader( fileReader ); - StringBuffer sb = new StringBuffer(); + StringBuilder sb = new StringBuilder(); boolean hasContent = false; @@ -122,7 +122,7 @@ public class LatinEntityResolutionReaderTest } } - private void assertProperRead( StringBuffer expected, String sourcePath, int bufSize ) + private void assertProperRead( StringBuilder expected, String sourcePath, int bufSize ) { try { @@ -145,7 +145,7 @@ public class LatinEntityResolutionReaderTest public void testReaderNormalBufsize() throws IOException { - StringBuffer expected = new StringBuffer(); + StringBuilder expected = new StringBuilder(); expected.append( "\n" ); expected.append( " \n" ); @@ -161,7 +161,7 @@ public class LatinEntityResolutionReaderTest public void testReaderSmallBufsize() throws IOException { - StringBuffer expected = new StringBuffer(); + StringBuilder expected = new StringBuilder(); expected.append( "\n" ); expected.append( " \n" ); @@ -177,7 +177,7 @@ public class LatinEntityResolutionReaderTest public void testReaderRediculouslyTinyBufsize() throws IOException { - StringBuffer expected = new StringBuffer(); + StringBuilder expected = new StringBuilder(); expected.append( "\n" ); expected.append( " \n" ); @@ -193,7 +193,7 @@ public class LatinEntityResolutionReaderTest public void testReaderHugeBufsize() throws IOException { - StringBuffer expected = new StringBuffer(); + StringBuilder expected = new StringBuilder(); expected.append( "\n" ); expected.append( " \n" ); diff --git a/archiva-modules/archiva-base/archiva-xml-tools/src/test/java/org/apache/archiva/xml/XMLWriterTest.java b/archiva-modules/archiva-base/archiva-xml-tools/src/test/java/org/apache/archiva/xml/XMLWriterTest.java index fe7e7d062..4791311da 100644 --- a/archiva-modules/archiva-base/archiva-xml-tools/src/test/java/org/apache/archiva/xml/XMLWriterTest.java +++ b/archiva-modules/archiva-base/archiva-xml-tools/src/test/java/org/apache/archiva/xml/XMLWriterTest.java @@ -38,7 +38,7 @@ public class XMLWriterTest public void testWrite() throws Exception { - StringBuffer expected = new StringBuffer(); + StringBuilder expected = new StringBuilder(); expected.append( "\n" ); expected.append( "\n" ); diff --git a/archiva-modules/archiva-web/archiva-webapp-js/src/main/webapp/js/text.js b/archiva-modules/archiva-web/archiva-webapp-js/src/main/webapp/js/text.js index 47f62ab22..39016dc03 100644 --- a/archiva-modules/archiva-web/archiva-webapp-js/src/main/webapp/js/text.js +++ b/archiva-modules/archiva-web/archiva-webapp-js/src/main/webapp/js/text.js @@ -268,10 +268,10 @@ define(['module'], function (module) { file = new java.io.File(url), lineSeparator = java.lang.System.getProperty("line.separator"), input = new java.io.BufferedReader(new java.io.InputStreamReader(new java.io.FileInputStream(file), encoding)), - stringBuffer, line, + StringBuilder, line, content = ''; try { - stringBuffer = new java.lang.StringBuffer(); + StringBuilder = new java.lang.StringBuilder(); line = input.readLine(); // Byte Order Mark (BOM) - The Unicode Standard, version 3.0, page 324 @@ -286,14 +286,14 @@ define(['module'], function (module) { line = line.substring(1); } - stringBuffer.append(line); + StringBuilder.append(line); while ((line = input.readLine()) !== null) { - stringBuffer.append(lineSeparator); - stringBuffer.append(line); + StringBuilder.append(lineSeparator); + StringBuilder.append(line); } //Make sure we return a JavaScript string and not a Java string. - content = String(stringBuffer.toString()); //String + content = String(StringBuilder.toString()); //String } finally { input.close(); } diff --git a/archiva-modules/archiva-web/archiva-webapp/src/test/java/org/apache/archiva/web/action/AbstractWebworkTestCase.java b/archiva-modules/archiva-web/archiva-webapp/src/test/java/org/apache/archiva/web/action/AbstractWebworkTestCase.java index 94f137688..f1cdc70e4 100644 --- a/archiva-modules/archiva-web/archiva-webapp/src/test/java/org/apache/archiva/web/action/AbstractWebworkTestCase.java +++ b/archiva-modules/archiva-web/archiva-webapp/src/test/java/org/apache/archiva/web/action/AbstractWebworkTestCase.java @@ -91,7 +91,7 @@ public abstract class AbstractWebworkTestCase assertNotNull( errors ); if ( errors.size() > 0 ) { - StringBuffer msg = new StringBuffer(); + StringBuilder msg = new StringBuilder(); msg.append( "Should have had no errors. but found the following errors." ); for ( String error : errors ) @@ -114,7 +114,7 @@ public abstract class AbstractWebworkTestCase if ( !StringUtils.equals( expectedStatus, (String) actualStatus ) ) { - StringBuffer msg = new StringBuffer(); + StringBuilder msg = new StringBuilder(); msg.append( "Unexpected status returned from method <" ); msg.append( methodName ).append( "> on action <" ); String clazzname = action.getClass().getName(); diff --git a/archiva-modules/archiva-web/archiva-webapp/src/test/java/org/apache/archiva/web/action/admin/connectors/proxy/SortProxyConnectorsActionTest.java b/archiva-modules/archiva-web/archiva-webapp/src/test/java/org/apache/archiva/web/action/admin/connectors/proxy/SortProxyConnectorsActionTest.java index 21469c692..b59e2a4bd 100644 --- a/archiva-modules/archiva-web/archiva-webapp/src/test/java/org/apache/archiva/web/action/admin/connectors/proxy/SortProxyConnectorsActionTest.java +++ b/archiva-modules/archiva-web/archiva-webapp/src/test/java/org/apache/archiva/web/action/admin/connectors/proxy/SortProxyConnectorsActionTest.java @@ -194,7 +194,7 @@ public class SortProxyConnectorsActionTest if ( orderFailedAt >= 0 ) { - StringBuffer msg = new StringBuffer(); + StringBuilder msg = new StringBuilder(); msg.append( "Failed expected order of the proxy connectors <" ); msg.append( StringUtils.join( targetRepoOrder, ", " ) ); diff --git a/archiva-modules/archiva-web/archiva-webdav/src/test/java/org/apache/archiva/webdav/AbstractRepositoryServletProxiedMetadataTestCase.java b/archiva-modules/archiva-web/archiva-webdav/src/test/java/org/apache/archiva/webdav/AbstractRepositoryServletProxiedMetadataTestCase.java index 2a21d22a0..a801845e5 100644 --- a/archiva-modules/archiva-web/archiva-webdav/src/test/java/org/apache/archiva/webdav/AbstractRepositoryServletProxiedMetadataTestCase.java +++ b/archiva-modules/archiva-web/archiva-webdav/src/test/java/org/apache/archiva/webdav/AbstractRepositoryServletProxiedMetadataTestCase.java @@ -71,7 +71,7 @@ public abstract class AbstractRepositoryServletProxiedMetadataTestCase protected String createVersionMetadata( String groupId, String artifactId, String version, String timestamp, String buildNumber, String lastUpdated ) { - StringBuffer buf = new StringBuffer(); + StringBuilder buf = new StringBuilder(); buf.append( "\n\n" ); buf.append( "\n" ); @@ -106,7 +106,7 @@ public abstract class AbstractRepositoryServletProxiedMetadataTestCase protected String createProjectMetadata( String groupId, String artifactId, String latest, String release, String[] versions ) { - StringBuffer buf = new StringBuffer(); + StringBuilder buf = new StringBuilder(); buf.append( "\n\n" ); buf.append( "\n" ); @@ -146,7 +146,7 @@ public abstract class AbstractRepositoryServletProxiedMetadataTestCase protected String createGroupMetadata( String groupId, String[] plugins ) { - StringBuffer buf = new StringBuffer(); + StringBuilder buf = new StringBuilder(); buf.append( "\n\n" ); buf.append( "\n" ); -- 2.39.5