[tomcat] branch master updated: Use StringBuilder instead of StringBuffer

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
3 messages Options
Reply | Threaded
Open this post in threaded view
|

[tomcat] branch master updated: Use StringBuilder instead of StringBuffer

Martin Grigorov
This is an automated email from the ASF dual-hosted git repository.

mgrigorov pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/tomcat.git


The following commit(s) were added to refs/heads/master by this push:
     new d106b2b  Use StringBuilder instead of StringBuffer
     new d905816  Merge pull request #312 from martin-g/master
d106b2b is described below

commit d106b2b0305e443261704ee44fa0ce8f696d1059
Author: Martin Tzvetanov Grigorov <[hidden email]>
AuthorDate: Fri Jul 3 10:29:04 2020 +0300

    Use StringBuilder instead of StringBuffer
   
    There is no need of synchronization when it is a method local variable.
   
    Append character instead of String when possible
   
    Replace more .append(String) with .append(char)
---
 java/org/apache/catalina/Container.java            |  2 +-
 .../authenticator/SingleSignOnSessionKey.java      |  2 +-
 .../apache/catalina/connector/CoyotePrincipal.java |  2 +-
 java/org/apache/catalina/connector/Response.java   |  4 ++--
 .../catalina/core/ApplicationFilterConfig.java     |  2 +-
 java/org/apache/catalina/core/StandardServer.java  |  2 +-
 java/org/apache/catalina/core/StandardService.java |  2 +-
 .../apache/catalina/ha/session/DeltaRequest.java   |  2 +-
 .../apache/catalina/ha/session/DeltaSession.java   |  2 +-
 java/org/apache/catalina/loader/WebappLoader.java  |  4 ++--
 java/org/apache/catalina/mbeans/MBeanDumper.java   |  4 ++--
 .../apache/catalina/realm/GenericPrincipal.java    |  4 ++--
 java/org/apache/catalina/realm/RealmBase.java      |  6 +++---
 java/org/apache/catalina/servlets/CGIServlet.java  | 12 +++++------
 .../apache/catalina/servlets/DefaultServlet.java   | 20 +++++++++---------
 java/org/apache/catalina/session/ManagerBase.java  |  2 +-
 .../apache/catalina/session/StandardSession.java   |  2 +-
 .../apache/catalina/ssi/ExpressionParseTree.java   |  4 ++--
 .../catalina/ssi/SSIServletExternalResolver.java   |  8 ++++----
 java/org/apache/catalina/startup/Catalina.java     |  6 +++---
 .../catalina/startup/CertificateCreateRule.java    |  6 +++---
 .../catalina/startup/ConnectorCreateRule.java      |  2 +-
 .../org/apache/catalina/startup/ContextConfig.java | 14 ++++++-------
 .../catalina/startup/ListenerCreateRule.java       |  2 +-
 .../apache/catalina/startup/SetNextNamingRule.java |  4 ++--
 java/org/apache/catalina/startup/Tomcat.java       |  4 ++--
 .../catalina/storeconfig/StoreFileMover.java       | 10 ++++-----
 .../apache/catalina/tribes/group/GroupChannel.java |  6 +++---
 .../org/apache/catalina/tribes/io/ChannelData.java |  8 ++++----
 .../catalina/tribes/membership/MemberImpl.java     | 14 ++++++-------
 .../membership/StaticMembershipProvider.java       |  4 ++--
 .../tribes/tipis/AbstractReplicatedMap.java        |  4 ++--
 java/org/apache/catalina/tribes/util/Arrays.java   |  8 ++++----
 .../apache/catalina/users/MemoryUserDatabase.java  |  2 +-
 java/org/apache/catalina/util/Extension.java       |  2 +-
 .../org/apache/catalina/util/ManifestResource.java |  2 +-
 java/org/apache/catalina/util/Strftime.java        |  2 +-
 .../catalina/valves/AbstractAccessLogValve.java    |  2 +-
 .../catalina/valves/ExtendedAccessLogValve.java    |  4 ++--
 .../catalina/valves/StuckThreadDetectionValve.java |  2 +-
 .../catalina/valves/rewrite/RewriteValve.java      |  6 +++---
 .../catalina/valves/rewrite/Substitution.java      |  2 +-
 java/org/apache/coyote/ajp/AjpMessage.java         |  2 +-
 java/org/apache/jasper/compiler/Generator.java     |  2 +-
 java/org/apache/jasper/compiler/PageDataImpl.java  | 18 ++++++++--------
 java/org/apache/juli/JdkLoggerFormatter.java       |  6 +++---
 java/org/apache/naming/AbstractRef.java            |  4 ++--
 java/org/apache/tomcat/util/Diagnostics.java       |  2 +-
 java/org/apache/tomcat/util/MultiThrowable.java    |  4 ++--
 .../util/bcel/classfile/ArrayElementValue.java     |  6 +++---
 java/org/apache/tomcat/util/buf/UriUtil.java       |  2 +-
 .../util/descriptor/web/ApplicationParameter.java  |  2 +-
 .../tomcat/util/descriptor/web/ContextEjb.java     |  2 +-
 .../util/descriptor/web/ContextEnvironment.java    |  2 +-
 .../tomcat/util/descriptor/web/ContextHandler.java |  2 +-
 .../util/descriptor/web/ContextLocalEjb.java       |  2 +-
 .../util/descriptor/web/ContextResource.java       |  2 +-
 .../util/descriptor/web/ContextResourceEnvRef.java |  2 +-
 .../util/descriptor/web/ContextResourceLink.java   |  2 +-
 .../tomcat/util/descriptor/web/ContextService.java |  2 +-
 .../util/descriptor/web/ContextTransaction.java    |  2 +-
 .../tomcat/util/descriptor/web/ErrorPage.java      |  2 +-
 .../tomcat/util/descriptor/web/FilterDef.java      |  2 +-
 .../tomcat/util/descriptor/web/FilterMap.java      |  2 +-
 .../tomcat/util/descriptor/web/LoginConfig.java    |  2 +-
 .../util/descriptor/web/MessageDestination.java    |  2 +-
 .../util/descriptor/web/MessageDestinationRef.java |  2 +-
 .../util/descriptor/web/SecurityCollection.java    |  2 +-
 .../util/descriptor/web/SecurityConstraint.java    |  2 +-
 .../util/descriptor/web/SecurityRoleRef.java       |  2 +-
 .../tomcat/util/descriptor/web/WebRuleSet.java     |  2 +-
 .../apache/tomcat/util/descriptor/web/WebXml.java  |  2 +-
 .../tomcat/util/digester/CallMethodRule.java       | 24 +++++++++++-----------
 .../apache/tomcat/util/digester/CallParamRule.java |  2 +-
 .../tomcat/util/digester/FactoryCreateRule.java    |  2 +-
 .../tomcat/util/digester/ObjectCreateRule.java     |  4 ++--
 .../apache/tomcat/util/digester/SetNextRule.java   |  6 +++---
 .../tomcat/util/digester/SetPropertiesRule.java    |  4 ++--
 .../tomcat/util/http/LegacyCookieProcessor.java    |  2 +-
 .../util/http/fileupload/FileUploadBase.java       |  2 +-
 .../apache/tomcat/util/modeler/ManagedBean.java    |  2 +-
 .../tomcat/util/modeler/NotificationInfo.java      |  2 +-
 java/org/apache/tomcat/util/net/AprEndpoint.java   |  6 +++---
 .../tomcat/websocket/DigestAuthenticator.java      | 10 ++++-----
 .../websocket/server/WsHandshakeRequest.java       |  4 ++--
 85 files changed, 180 insertions(+), 180 deletions(-)

diff --git a/java/org/apache/catalina/Container.java b/java/org/apache/catalina/Container.java
index f9da61e..98dd2be 100644
--- a/java/org/apache/catalina/Container.java
+++ b/java/org/apache/catalina/Container.java
@@ -305,7 +305,7 @@ public interface Container extends Lifecycle {
      * @return the configuration path
      */
     public static String getConfigPath(Container container, String resourceName) {
-        StringBuffer result = new StringBuffer();
+        StringBuilder result = new StringBuilder();
         Container host = null;
         Container engine = null;
         while (container != null) {
diff --git a/java/org/apache/catalina/authenticator/SingleSignOnSessionKey.java b/java/org/apache/catalina/authenticator/SingleSignOnSessionKey.java
index a4fb05b..a07946f 100644
--- a/java/org/apache/catalina/authenticator/SingleSignOnSessionKey.java
+++ b/java/org/apache/catalina/authenticator/SingleSignOnSessionKey.java
@@ -116,7 +116,7 @@ public class SingleSignOnSessionKey implements Serializable {
         sb.append(contextName);
         sb.append("], SessionID: [");
         sb.append(sessionId);
-        sb.append("]");
+        sb.append(']');
         return sb.toString();
     }
 }
diff --git a/java/org/apache/catalina/connector/CoyotePrincipal.java b/java/org/apache/catalina/connector/CoyotePrincipal.java
index 1ae5608..93d7c02 100644
--- a/java/org/apache/catalina/connector/CoyotePrincipal.java
+++ b/java/org/apache/catalina/connector/CoyotePrincipal.java
@@ -64,7 +64,7 @@ public class CoyotePrincipal implements Principal, Serializable {
     public String toString() {
         StringBuilder sb = new StringBuilder("CoyotePrincipal[");
         sb.append(this.name);
-        sb.append("]");
+        sb.append(']');
         return sb.toString();
     }
 
diff --git a/java/org/apache/catalina/connector/Response.java b/java/org/apache/catalina/connector/Response.java
index af9c811..ebd94f5 100644
--- a/java/org/apache/catalina/connector/Response.java
+++ b/java/org/apache/catalina/connector/Response.java
@@ -1797,10 +1797,10 @@ public class Response implements HttpServletResponse {
         }
         StringBuilder sb = new StringBuilder(path);
         if( sb.length() > 0 ) { // jsessionid can't be first.
-            sb.append(";");
+            sb.append(';');
             sb.append(SessionConfig.getSessionUriParamName(
                     request.getContext()));
-            sb.append("=");
+            sb.append('=');
             sb.append(sessionId);
         }
         sb.append(anchor);
diff --git a/java/org/apache/catalina/core/ApplicationFilterConfig.java b/java/org/apache/catalina/core/ApplicationFilterConfig.java
index fa89d2c..e4fec4f 100644
--- a/java/org/apache/catalina/core/ApplicationFilterConfig.java
+++ b/java/org/apache/catalina/core/ApplicationFilterConfig.java
@@ -209,7 +209,7 @@ public final class ApplicationFilterConfig implements FilterConfig, Serializable
         sb.append(filterDef.getFilterName());
         sb.append(", filterClass=");
         sb.append(filterDef.getFilterClass());
-        sb.append("]");
+        sb.append(']');
         return sb.toString();
     }
 
diff --git a/java/org/apache/catalina/core/StandardServer.java b/java/org/apache/catalina/core/StandardServer.java
index 5a28f6f..cfbdc09 100644
--- a/java/org/apache/catalina/core/StandardServer.java
+++ b/java/org/apache/catalina/core/StandardServer.java
@@ -828,7 +828,7 @@ public final class StandardServer extends LifecycleMBeanBase implements Server {
     public String toString() {
         StringBuilder sb = new StringBuilder("StandardServer[");
         sb.append(getPort());
-        sb.append("]");
+        sb.append(']');
         return sb.toString();
     }
 
diff --git a/java/org/apache/catalina/core/StandardService.java b/java/org/apache/catalina/core/StandardService.java
index 5898b1e..05965ca 100644
--- a/java/org/apache/catalina/core/StandardService.java
+++ b/java/org/apache/catalina/core/StandardService.java
@@ -325,7 +325,7 @@ public class StandardService extends LifecycleMBeanBase implements Service {
     public String toString() {
         StringBuilder sb = new StringBuilder("StandardService[");
         sb.append(getName());
-        sb.append("]");
+        sb.append(']');
         return sb.toString();
     }
 
diff --git a/java/org/apache/catalina/ha/session/DeltaRequest.java b/java/org/apache/catalina/ha/session/DeltaRequest.java
index c13da90..b4aa789 100644
--- a/java/org/apache/catalina/ha/session/DeltaRequest.java
+++ b/java/org/apache/catalina/ha/session/DeltaRequest.java
@@ -403,7 +403,7 @@ public class DeltaRequest implements Externalizable {
             StringBuilder buf = new StringBuilder("AttributeInfo[type=");
             buf.append(getType()).append(", action=").append(getAction());
             buf.append(", name=").append(getName()).append(", value=").append(getValue());
-            buf.append(", addr=").append(super.toString()).append("]");
+            buf.append(", addr=").append(super.toString()).append(']');
             return buf.toString();
         }
 
diff --git a/java/org/apache/catalina/ha/session/DeltaSession.java b/java/org/apache/catalina/ha/session/DeltaSession.java
index 8d0f8e1..966ff6b 100644
--- a/java/org/apache/catalina/ha/session/DeltaSession.java
+++ b/java/org/apache/catalina/ha/session/DeltaSession.java
@@ -562,7 +562,7 @@ public class DeltaSession extends StandardSession implements Externalizable,Clus
         StringBuilder sb = new StringBuilder();
         sb.append("DeltaSession[");
         sb.append(id);
-        sb.append("]");
+        sb.append(']');
         return sb.toString();
     }
 
diff --git a/java/org/apache/catalina/loader/WebappLoader.java b/java/org/apache/catalina/loader/WebappLoader.java
index 0e03855..91cb3ad 100644
--- a/java/org/apache/catalina/loader/WebappLoader.java
+++ b/java/org/apache/catalina/loader/WebappLoader.java
@@ -243,7 +243,7 @@ public class WebappLoader extends LifecycleMBeanBase implements Loader{
         String repositories[]=getLoaderRepositories();
         StringBuilder sb=new StringBuilder();
         for (String repository : repositories) {
-            sb.append(repository).append(":");
+            sb.append(repository).append(':');
         }
         return sb.toString();
     }
@@ -548,7 +548,7 @@ public class WebappLoader extends LifecycleMBeanBase implements Loader{
 
         String contextName = context.getName();
         if (!contextName.startsWith("/")) {
-            name.append("/");
+            name.append('/');
         }
         name.append(contextName);
 
diff --git a/java/org/apache/catalina/mbeans/MBeanDumper.java b/java/org/apache/catalina/mbeans/MBeanDumper.java
index 668d298..adddd6a 100644
--- a/java/org/apache/catalina/mbeans/MBeanDumper.java
+++ b/java/org/apache/catalina/mbeans/MBeanDumper.java
@@ -218,10 +218,10 @@ public class MBeanDumper {
             CompositeData composite = CompositeData.class.cast(value);
             Set<String> keys = composite.getCompositeType().keySet();
             for (String key : keys) {
-                sb.append(sep).append(key).append("=").append(composite.get(key));
+                sb.append(sep).append(key).append('=').append(composite.get(key));
                 sep = ", ";
             }
-            sb.append("}");
+            sb.append('}');
             valueString = sb.toString();
         } else {
             valueString = value.toString();
diff --git a/java/org/apache/catalina/realm/GenericPrincipal.java b/java/org/apache/catalina/realm/GenericPrincipal.java
index 72482d5..6d57730 100644
--- a/java/org/apache/catalina/realm/GenericPrincipal.java
+++ b/java/org/apache/catalina/realm/GenericPrincipal.java
@@ -284,9 +284,9 @@ public class GenericPrincipal implements TomcatPrincipal, Serializable {
     public String toString() {
         StringBuilder sb = new StringBuilder("GenericPrincipal[");
         sb.append(this.name);
-        sb.append("(");
+        sb.append('(');
         for (String role : roles) {
-            sb.append(role).append(",");
+            sb.append(role).append(',');
         }
         sb.append(")]");
         return sb.toString();
diff --git a/java/org/apache/catalina/realm/RealmBase.java b/java/org/apache/catalina/realm/RealmBase.java
index b09bb90..f429447 100644
--- a/java/org/apache/catalina/realm/RealmBase.java
+++ b/java/org/apache/catalina/realm/RealmBase.java
@@ -1041,17 +1041,17 @@ public abstract class RealmBase extends LifecycleMBeanBase implements Realm {
         file.append(protocol).append("://").append(host);
         // Host with port
         if(redirectPort != 443) {
-            file.append(":").append(redirectPort);
+            file.append(':').append(redirectPort);
         }
         // URI
         file.append(request.getRequestURI());
         String requestedSessionId = request.getRequestedSessionId();
         if ((requestedSessionId != null) &&
             request.isRequestedSessionIdFromURL()) {
-            file.append(";");
+            file.append(';');
             file.append(SessionConfig.getSessionUriParamName(
                     request.getContext()));
-            file.append("=");
+            file.append('=');
             file.append(requestedSessionId);
         }
         String queryString = request.getQueryString();
diff --git a/java/org/apache/catalina/servlets/CGIServlet.java b/java/org/apache/catalina/servlets/CGIServlet.java
index 03cdfb0..e5df2d9 100644
--- a/java/org/apache/catalina/servlets/CGIServlet.java
+++ b/java/org/apache/catalina/servlets/CGIServlet.java
@@ -1161,12 +1161,12 @@ public final class CGIServlet extends HttpServlet {
                         new StringTokenizer (pathInfo, "/");
                 // start with first element
                 while (pathWalker.hasMoreElements() && (is == null)) {
-                    srcPath.append("/");
+                    srcPath.append('/');
                     srcPath.append(pathWalker.nextElement());
                     is = context.getResourceAsStream(srcPath.toString());
                 }
                 destPath.append(tmpDir);
-                destPath.append("/");
+                destPath.append('/');
                 destPath.append(srcPath);
             }
 
@@ -1252,13 +1252,13 @@ public final class CGIServlet extends HttpServlet {
                     sb.append(entry.getKey());
                     sb.append(": [");
                     sb.append(blanksToString(entry.getValue(), "will be set to blank"));
-                    sb.append("]");
+                    sb.append(']');
                     sb.append(System.lineSeparator());
                 }
 
                 sb.append("Derived Command :[");
                 sb.append(nullsToBlanks(command));
-                sb.append("]");
+                sb.append(']');
                 sb.append(System.lineSeparator());
 
 
@@ -1266,7 +1266,7 @@ public final class CGIServlet extends HttpServlet {
                 if (workingDirectory != null) {
                     sb.append(workingDirectory.toString());
                 }
-                sb.append("]");
+                sb.append(']');
                 sb.append(System.lineSeparator());
 
                 sb.append("Command Line Params:");
@@ -1274,7 +1274,7 @@ public final class CGIServlet extends HttpServlet {
                 for (String param : cmdLineParameters) {
                     sb.append("  [");
                     sb.append(param);
-                    sb.append("]");
+                    sb.append(']');
                     sb.append(System.lineSeparator());
                 }
             } else {
diff --git a/java/org/apache/catalina/servlets/DefaultServlet.java b/java/org/apache/catalina/servlets/DefaultServlet.java
index 8649bb2..5ffc548 100644
--- a/java/org/apache/catalina/servlets/DefaultServlet.java
+++ b/java/org/apache/catalina/servlets/DefaultServlet.java
@@ -1611,7 +1611,7 @@ public class DefaultServlet extends HttpServlet {
         sb.append("<listing ");
         sb.append(" contextPath='");
         sb.append(contextPath);
-        sb.append("'");
+        sb.append('\'');
         sb.append(" directory='");
         sb.append(resource.getName());
         sb.append("' ");
@@ -1645,25 +1645,25 @@ public class DefaultServlet extends HttpServlet {
             sb.append("<entry");
             sb.append(" type='")
               .append(childResource.isDirectory()?"dir":"file")
-              .append("'");
+              .append('\'');
             sb.append(" urlPath='")
               .append(rewrittenContextPath)
               .append(rewriteUrl(directoryWebappPath + entry))
               .append(childResource.isDirectory()?"/":"")
-              .append("'");
+              .append('\'');
             if (childResource.isFile()) {
                 sb.append(" size='")
                   .append(renderSize(childResource.getContentLength()))
-                  .append("'");
+                  .append('\'');
             }
             sb.append(" date='")
               .append(childResource.getLastModifiedHttp())
-              .append("'");
+              .append('\'');
 
-            sb.append(">");
+            sb.append('>');
             sb.append(Escape.htmlElementContent(entry));
             if (childResource.isDirectory())
-                sb.append("/");
+                sb.append('/');
             sb.append("</entry>");
         }
         sb.append("</entries>");
@@ -1781,7 +1781,7 @@ public class DefaultServlet extends HttpServlet {
                 parent = "/";
             sb.append(rewriteUrl(parent));
             if (!parent.endsWith("/"))
-                sb.append("/");
+                sb.append('/');
             sb.append("\">");
             sb.append("<b>");
             sb.append(sm.getString("directory.parent", parent));
@@ -1863,11 +1863,11 @@ public class DefaultServlet extends HttpServlet {
             sb.append(rewrittenContextPath);
             sb.append(rewriteUrl(childResource.getWebappPath()));
             if (childResource.isDirectory())
-                sb.append("/");
+                sb.append('/');
             sb.append("\"><tt>");
             sb.append(Escape.htmlElementContent(filename));
             if (childResource.isDirectory())
-                sb.append("/");
+                sb.append('/');
             sb.append("</tt></a></td>\r\n");
 
             sb.append("<td align=\"right\"><tt>");
diff --git a/java/org/apache/catalina/session/ManagerBase.java b/java/org/apache/catalina/session/ManagerBase.java
index 7d5ed97..8bd2b71 100644
--- a/java/org/apache/catalina/session/ManagerBase.java
+++ b/java/org/apache/catalina/session/ManagerBase.java
@@ -1159,7 +1159,7 @@ public abstract class ManagerBase extends LifecycleMBeanBase implements Manager
     public String listSessionIds() {
         StringBuilder sb = new StringBuilder();
         for (String s : sessions.keySet()) {
-            sb.append(s).append(" ");
+            sb.append(s).append(' ');
         }
         return sb.toString();
     }
diff --git a/java/org/apache/catalina/session/StandardSession.java b/java/org/apache/catalina/session/StandardSession.java
index ace01d9..f755e25 100644
--- a/java/org/apache/catalina/session/StandardSession.java
+++ b/java/org/apache/catalina/session/StandardSession.java
@@ -1007,7 +1007,7 @@ public class StandardSession implements HttpSession, Session, Serializable {
         StringBuilder sb = new StringBuilder();
         sb.append("StandardSession[");
         sb.append(id);
-        sb.append("]");
+        sb.append(']');
         return sb.toString();
     }
 
diff --git a/java/org/apache/catalina/ssi/ExpressionParseTree.java b/java/org/apache/catalina/ssi/ExpressionParseTree.java
index f2c15c7..f32d08b 100644
--- a/java/org/apache/catalina/ssi/ExpressionParseTree.java
+++ b/java/org/apache/catalina/ssi/ExpressionParseTree.java
@@ -144,7 +144,7 @@ public class ExpressionParseTree {
                         nodeStack.add(0, currStringNode);
                     } else {
                         // Add to the existing
-                        currStringNode.value.append(" ");
+                        currStringNode.value.append(' ');
                         currStringNode.value.append(et.getTokenValue());
                     }
                     break;
@@ -446,4 +446,4 @@ public class ExpressionParseTree {
             return left + " " + right + " LT";
         }
     }
-}
\ No newline at end of file
+}
diff --git a/java/org/apache/catalina/ssi/SSIServletExternalResolver.java b/java/org/apache/catalina/ssi/SSIServletExternalResolver.java
index ae5f3fe..2143838 100644
--- a/java/org/apache/catalina/ssi/SSIServletExternalResolver.java
+++ b/java/org/apache/catalina/ssi/SSIServletExternalResolver.java
@@ -321,11 +321,11 @@ public class SSIServletExternalResolver implements SSIExternalResolver {
                 retVal = req.getProtocol();
             } else if (nameParts[1].equals("SOFTWARE")) {
                 StringBuilder rv = new StringBuilder(context.getServerInfo());
-                rv.append(" ");
+                rv.append(' ');
                 rv.append(System.getProperty("java.vm.name"));
-                rv.append("/");
+                rv.append('/');
                 rv.append(System.getProperty("java.vm.version"));
-                rv.append(" ");
+                rv.append(' ');
                 rv.append(System.getProperty("os.name"));
                 retVal = rv.toString();
             }
@@ -567,4 +567,4 @@ public class SSIServletExternalResolver implements SSIExternalResolver {
             return path;
         }
     }
-}
\ No newline at end of file
+}
diff --git a/java/org/apache/catalina/startup/Catalina.java b/java/org/apache/catalina/startup/Catalina.java
index a0955c1..2c3f994 100644
--- a/java/org/apache/catalina/startup/Catalina.java
+++ b/java/org/apache/catalina/startup/Catalina.java
@@ -917,14 +917,14 @@ public class Catalina {
         code.append(" implements ");
         code.append(ServerXml.class.getName().replace('$', '.')).append(" {").append(System.lineSeparator());
         code.append("public void load(").append(Catalina.class.getName());
-        code.append(" ").append(digester.toVariableName(this)).append(") {").append(System.lineSeparator());
+        code.append(' ').append(digester.toVariableName(this)).append(") {").append(System.lineSeparator());
     }
 
 
     protected void generateClassFooter(Digester digester) {
         StringBuilder code = digester.getGeneratedCode();
-        code.append("}").append(System.lineSeparator());
-        code.append("}").append(System.lineSeparator());
+        code.append('}').append(System.lineSeparator());
+        code.append('}').append(System.lineSeparator());
     }
 
 
diff --git a/java/org/apache/catalina/startup/CertificateCreateRule.java b/java/org/apache/catalina/startup/CertificateCreateRule.java
index f41c001..5c305e4 100644
--- a/java/org/apache/catalina/startup/CertificateCreateRule.java
+++ b/java/org/apache/catalina/startup/CertificateCreateRule.java
@@ -45,10 +45,10 @@ public class CertificateCreateRule extends Rule {
 
         StringBuilder code = digester.getGeneratedCode();
         if (code != null) {
-            code.append(SSLHostConfigCertificate.class.getName()).append(" ").append(digester.toVariableName(certificate));
+            code.append(SSLHostConfigCertificate.class.getName()).append(' ').append(digester.toVariableName(certificate));
             code.append(" = new ").append(SSLHostConfigCertificate.class.getName());
-            code.append("(").append(digester.toVariableName(sslHostConfig));
-            code.append(", ").append(Type.class.getName().replace('$', '.')).append(".").append(type).append(");");
+            code.append('(').append(digester.toVariableName(sslHostConfig));
+            code.append(", ").append(Type.class.getName().replace('$', '.')).append('.').append(type).append(");");
             code.append(System.lineSeparator());
         }
     }
diff --git a/java/org/apache/catalina/startup/ConnectorCreateRule.java b/java/org/apache/catalina/startup/ConnectorCreateRule.java
index 875fea7..d74e1a9 100644
--- a/java/org/apache/catalina/startup/ConnectorCreateRule.java
+++ b/java/org/apache/catalina/startup/ConnectorCreateRule.java
@@ -77,7 +77,7 @@ public class ConnectorCreateRule extends Rule {
         StringBuilder code = digester.getGeneratedCode();
         if (code != null) {
             code.append(System.lineSeparator());
-            code.append(Connector.class.getName()).append(" ").append(digester.toVariableName(con));
+            code.append(Connector.class.getName()).append(' ').append(digester.toVariableName(con));
             code.append(" = new ").append(Connector.class.getName());
             code.append("(new ").append(con.getProtocolHandlerClassName()).append("());");
             code.append(System.lineSeparator());
diff --git a/java/org/apache/catalina/startup/ContextConfig.java b/java/org/apache/catalina/startup/ContextConfig.java
index 14b815f..307d4b8 100644
--- a/java/org/apache/catalina/startup/ContextConfig.java
+++ b/java/org/apache/catalina/startup/ContextConfig.java
@@ -475,7 +475,7 @@ public class ContextConfig implements LifecycleListener {
 
 
     protected static String getContextXmlPackageName(Container container) {
-        StringBuffer result = new StringBuffer();
+        StringBuilder result = new StringBuilder();
         Container host = null;
         Container engine = null;
         while (container != null) {
@@ -516,26 +516,26 @@ public class ContextConfig implements LifecycleListener {
 
     protected void generateClassHeader(Digester digester, String packageName, String resourceName) {
         StringBuilder code = digester.getGeneratedCode();
-        code.append("package ").append(packageName).append(";").append(System.lineSeparator());
+        code.append("package ").append(packageName).append(';').append(System.lineSeparator());
         code.append("public class ").append(resourceName).append(" implements ");
         code.append(ContextXml.class.getName().replace('$', '.'));
         code.append(" {").append(System.lineSeparator());
         code.append("public void load(");
         code.append(Context.class.getName());
         String contextArgument = digester.toVariableName(context);
-        code.append(" ").append(contextArgument).append(") {").append(System.lineSeparator());
+        code.append(' ').append(contextArgument).append(") {").append(System.lineSeparator());
         // Create a new variable with the concrete type
         digester.setKnown(context);
-        code.append(context.getClass().getName()).append(" ").append(digester.toVariableName(context));
+        code.append(context.getClass().getName()).append(' ').append(digester.toVariableName(context));
         code.append(" = (").append(context.getClass().getName()).append(") ").append(contextArgument);
-        code.append(";").append(System.lineSeparator());
+        code.append(';').append(System.lineSeparator());
     }
 
 
     protected void generateClassFooter(Digester digester) {
         StringBuilder code = digester.getGeneratedCode();
-        code.append("}").append(System.lineSeparator());
-        code.append("}").append(System.lineSeparator());
+        code.append('}').append(System.lineSeparator());
+        code.append('}').append(System.lineSeparator());
     }
 
 
diff --git a/java/org/apache/catalina/startup/ListenerCreateRule.java b/java/org/apache/catalina/startup/ListenerCreateRule.java
index 9f1d5e1..c133890 100644
--- a/java/org/apache/catalina/startup/ListenerCreateRule.java
+++ b/java/org/apache/catalina/startup/ListenerCreateRule.java
@@ -60,7 +60,7 @@ public class ListenerCreateRule extends ObjectCreateRule {
                 digester.push(instance);
                 StringBuilder code = digester.getGeneratedCode();
                 if (code != null) {
-                    code.append(OptionalListener.class.getName().replace('$', '.')).append(" ");
+                    code.append(OptionalListener.class.getName().replace('$', '.')).append(' ');
                     code.append(digester.toVariableName(instance)).append(" = new ");
                     code.append(OptionalListener.class.getName().replace('$', '.')).append("(\"").append(className).append("\");");
                     code.append(System.lineSeparator());
diff --git a/java/org/apache/catalina/startup/SetNextNamingRule.java b/java/org/apache/catalina/startup/SetNextNamingRule.java
index 20d7e3c..cc9097a 100644
--- a/java/org/apache/catalina/startup/SetNextNamingRule.java
+++ b/java/org/apache/catalina/startup/SetNextNamingRule.java
@@ -113,7 +113,7 @@ public class SetNextNamingRule extends Rule {
             } else {
                 code.append(digester.toVariableName(namingResources));
             }
-            code.append(".").append(methodName).append("(");
+            code.append(".").append(methodName).append('(');
             code.append(digester.toVariableName(child)).append(");");
             code.append(System.lineSeparator());
         }
@@ -130,7 +130,7 @@ public class SetNextNamingRule extends Rule {
         sb.append(methodName);
         sb.append(", paramType=");
         sb.append(paramType);
-        sb.append("]");
+        sb.append(']');
         return sb.toString();
     }
 
diff --git a/java/org/apache/catalina/startup/Tomcat.java b/java/org/apache/catalina/startup/Tomcat.java
index 5de7256..5ac0154 100644
--- a/java/org/apache/catalina/startup/Tomcat.java
+++ b/java/org/apache/catalina/startup/Tomcat.java
@@ -988,9 +988,9 @@ public class Tomcat {
         loggerName.append("].[");
         // Context name
         if (contextName == null || contextName.equals("")) {
-            loggerName.append("/");
+            loggerName.append('/');
         } else if (contextName.startsWith("##")) {
-            loggerName.append("/");
+            loggerName.append('/');
             loggerName.append(contextName);
         }
         loggerName.append(']');
diff --git a/java/org/apache/catalina/storeconfig/StoreFileMover.java b/java/org/apache/catalina/storeconfig/StoreFileMover.java
index a59b9c1..b52d5b8 100644
--- a/java/org/apache/catalina/storeconfig/StoreFileMover.java
+++ b/java/org/apache/catalina/storeconfig/StoreFileMover.java
@@ -200,14 +200,14 @@ public class StoreFileMover {
         String ts = (new Timestamp(System.currentTimeMillis())).toString();
         //        yyyy-mm-dd hh:mm:ss
         //        0123456789012345678
-        StringBuffer sb = new StringBuffer(".");
-        sb.append(ts.substring(0, 10));
+        StringBuilder sb = new StringBuilder(".");
+        sb.append(ts, 0, 10);
         sb.append('.');
-        sb.append(ts.substring(11, 13));
+        sb.append(ts, 11, 13);
         sb.append('-');
-        sb.append(ts.substring(14, 16));
+        sb.append(ts, 14, 16);
         sb.append('-');
-        sb.append(ts.substring(17, 19));
+        sb.append(ts, 17, 19);
         return sb.toString();
     }
 
diff --git a/java/org/apache/catalina/tribes/group/GroupChannel.java b/java/org/apache/catalina/tribes/group/GroupChannel.java
index 9bc45bd..1bb558a 100644
--- a/java/org/apache/catalina/tribes/group/GroupChannel.java
+++ b/java/org/apache/catalina/tribes/group/GroupChannel.java
@@ -435,13 +435,13 @@ public class GroupChannel extends ChannelInterceptorBase
                 while ( next != null ) {
                     int nflag = next.getOptionFlag();
                     if (nflag!=0 && (((flag & nflag) == flag ) || ((flag & nflag) == nflag)) ) {
-                        conflicts.append("[");
+                        conflicts.append('[');
                         conflicts.append(first.getClass().getName());
-                        conflicts.append(":");
+                        conflicts.append(':');
                         conflicts.append(flag);
                         conflicts.append(" == ");
                         conflicts.append(next.getClass().getName());
-                        conflicts.append(":");
+                        conflicts.append(':');
                         conflicts.append(nflag);
                         conflicts.append("] ");
                     }//end if
diff --git a/java/org/apache/catalina/tribes/io/ChannelData.java b/java/org/apache/catalina/tribes/io/ChannelData.java
index 17cdb1d..c9b1ed3 100644
--- a/java/org/apache/catalina/tribes/io/ChannelData.java
+++ b/java/org/apache/catalina/tribes/io/ChannelData.java
@@ -358,15 +358,15 @@ public class ChannelData implements ChannelMessage {
         buf.append("ClusterData[src=");
         buf.append(getAddress()).append("; id=");
         buf.append(bToS(getUniqueId())).append("; sent=");
-        buf.append(new Timestamp(this.getTimestamp()).toString()).append("]");
+        buf.append(new Timestamp(this.getTimestamp()).toString()).append(']');
         return buf.toString();
     }
 
     public static String bToS(byte[] data) {
         StringBuilder buf = new StringBuilder(4*16);
-        buf.append("{");
-        for (int i=0; data!=null && i<data.length; i++ ) buf.append(String.valueOf(data[i])).append(" ");
-        buf.append("}");
+        buf.append('{');
+        for (int i=0; data!=null && i<data.length; i++ ) buf.append(String.valueOf(data[i])).append(' ');
+        buf.append('}');
         return buf.toString();
     }
 
diff --git a/java/org/apache/catalina/tribes/membership/MemberImpl.java b/java/org/apache/catalina/tribes/membership/MemberImpl.java
index 8e994e0..e651d90 100644
--- a/java/org/apache/catalina/tribes/membership/MemberImpl.java
+++ b/java/org/apache/catalina/tribes/membership/MemberImpl.java
@@ -518,9 +518,9 @@ public class MemberImpl implements Member, java.io.Externalizable {
     @Override
     public String toString()  {
         StringBuilder buf = new StringBuilder(getClass().getName());
-        buf.append("[");
-        buf.append(getName()).append(",");
-        buf.append(getHostname()).append(",");
+        buf.append('[');
+        buf.append(getName()).append(',');
+        buf.append(getHostname()).append(',');
         buf.append(port).append(", alive=");
         buf.append(memberAliveTime).append(", ");
         buf.append("securePort=").append(securePort).append(", ");
@@ -529,7 +529,7 @@ public class MemberImpl implements Member, java.io.Externalizable {
         buf.append("payload=").append(bToS(this.payload,8)).append(", ");
         buf.append("command=").append(bToS(this.command,8)).append(", ");
         buf.append("domain=").append(bToS(this.domain,8));
-        buf.append("]");
+        buf.append(']');
         return buf.toString();
     }
     public static String bToS(byte[] data) {
@@ -537,15 +537,15 @@ public class MemberImpl implements Member, java.io.Externalizable {
     }
     public static String bToS(byte[] data, int max) {
         StringBuilder buf = new StringBuilder(4*16);
-        buf.append("{");
+        buf.append('{');
         for (int i=0; data!=null && i<data.length; i++ ) {
-            buf.append(String.valueOf(data[i])).append(" ");
+            buf.append(String.valueOf(data[i])).append(' ');
             if ( i==max ) {
                 buf.append("...("+data.length+")");
                 break;
             }
         }
-        buf.append("}");
+        buf.append('}');
         return buf.toString();
     }
 
diff --git a/java/org/apache/catalina/tribes/membership/StaticMembershipProvider.java b/java/org/apache/catalina/tribes/membership/StaticMembershipProvider.java
index 93b3385..4bd09f1 100644
--- a/java/org/apache/catalina/tribes/membership/StaticMembershipProvider.java
+++ b/java/org/apache/catalina/tribes/membership/StaticMembershipProvider.java
@@ -372,7 +372,7 @@ public class StaticMembershipProvider extends MembershipProviderBase implements
             buf.append(getTypeDesc());
             buf.append("; member=");
             buf.append(member);
-            buf.append("]");
+            buf.append(']');
             return buf.toString();
         }
 
@@ -404,4 +404,4 @@ public class StaticMembershipProvider extends MembershipProviderBase implements
             }
         }
     }
-}
\ No newline at end of file
+}
diff --git a/java/org/apache/catalina/tribes/tipis/AbstractReplicatedMap.java b/java/org/apache/catalina/tribes/tipis/AbstractReplicatedMap.java
index 9525694..689decd 100644
--- a/java/org/apache/catalina/tribes/tipis/AbstractReplicatedMap.java
+++ b/java/org/apache/catalina/tribes/tipis/AbstractReplicatedMap.java
@@ -1427,7 +1427,7 @@ public abstract class AbstractReplicatedMap<K,V>
             buf.append(key);
             buf.append("; value=");
             buf.append(value);
-            buf.append("]");
+            buf.append(']');
             return buf.toString();
         }
 
@@ -1644,4 +1644,4 @@ public abstract class AbstractReplicatedMap<K,V>
             return available;
         }
     }
-}
\ No newline at end of file
+}
diff --git a/java/org/apache/catalina/tribes/util/Arrays.java b/java/org/apache/catalina/tribes/util/Arrays.java
index 36ff86a..5476545 100644
--- a/java/org/apache/catalina/tribes/util/Arrays.java
+++ b/java/org/apache/catalina/tribes/util/Arrays.java
@@ -71,7 +71,7 @@ public class Arrays {
                 }
             }
         }
-        buf.append("}");
+        buf.append('}');
         return buf.toString();
     }
 
@@ -87,7 +87,7 @@ public class Arrays {
                 buf.append(", ").append(data[i]);
             }
         }
-        buf.append("}");
+        buf.append('}');
         return buf.toString();
     }
 
@@ -103,7 +103,7 @@ public class Arrays {
                 buf.append(", ").append(data[i].getName());
             }
         }
-        buf.append("}");
+        buf.append('}');
         return buf.toString();
     }
 
@@ -211,4 +211,4 @@ public class Arrays {
     public static byte[] convert(String s) {
         return s.getBytes(StandardCharsets.ISO_8859_1);
     }
-}
\ No newline at end of file
+}
diff --git a/java/org/apache/catalina/users/MemoryUserDatabase.java b/java/org/apache/catalina/users/MemoryUserDatabase.java
index a9d3fc8..03e9fdd 100644
--- a/java/org/apache/catalina/users/MemoryUserDatabase.java
+++ b/java/org/apache/catalina/users/MemoryUserDatabase.java
@@ -712,7 +712,7 @@ public class MemoryUserDatabase implements UserDatabase {
         sb.append(this.roles.size());
         sb.append(",userCount=");
         sb.append(this.users.size());
-        sb.append("]");
+        sb.append(']');
         return sb.toString();
     }
 }
diff --git a/java/org/apache/catalina/util/Extension.java b/java/org/apache/catalina/util/Extension.java
index cf9489a..172f313 100644
--- a/java/org/apache/catalina/util/Extension.java
+++ b/java/org/apache/catalina/util/Extension.java
@@ -242,7 +242,7 @@ public final class Extension {
             sb.append(", specificationVersion=");
             sb.append(specificationVersion);
         }
-        sb.append("]");
+        sb.append(']');
         return sb.toString();
     }
 
diff --git a/java/org/apache/catalina/util/ManifestResource.java b/java/org/apache/catalina/util/ManifestResource.java
index 50776d2..2402b51 100644
--- a/java/org/apache/catalina/util/ManifestResource.java
+++ b/java/org/apache/catalina/util/ManifestResource.java
@@ -128,7 +128,7 @@ public class ManifestResource {
             case WAR : sb.append(", resourceType=WAR"); break;
             case APPLICATION : sb.append(", resourceType=APPLICATION"); break;
         }
-        sb.append("]");
+        sb.append(']');
         return sb.toString();
     }
 
diff --git a/java/org/apache/catalina/util/Strftime.java b/java/org/apache/catalina/util/Strftime.java
index a09e5b1..a051c8a 100644
--- a/java/org/apache/catalina/util/Strftime.java
+++ b/java/org/apache/catalina/util/Strftime.java
@@ -184,7 +184,7 @@ public class Strftime {
                 } else {
                     if ( !inside && c != ' ' ) {
                         //We start a literal, which we need to quote
-                        buf.append("'");
+                        buf.append('\'');
                         inside = true;
                     }
 
diff --git a/java/org/apache/catalina/valves/AbstractAccessLogValve.java b/java/org/apache/catalina/valves/AbstractAccessLogValve.java
index e5896c2..0a3fe31 100644
--- a/java/org/apache/catalina/valves/AbstractAccessLogValve.java
+++ b/java/org/apache/catalina/valves/AbstractAccessLogValve.java
@@ -833,7 +833,7 @@ public abstract class AbstractAccessLogValve extends ValveBase implements Access
             if(info != null) {
                 buf.append(info.getWorkerThreadName());
             } else {
-                buf.append("-");
+                buf.append('-');
             }
         }
     }
diff --git a/java/org/apache/catalina/valves/ExtendedAccessLogValve.java b/java/org/apache/catalina/valves/ExtendedAccessLogValve.java
index 10893d0..c791c12 100644
--- a/java/org/apache/catalina/valves/ExtendedAccessLogValve.java
+++ b/java/org/apache/catalina/valves/ExtendedAccessLogValve.java
@@ -339,7 +339,7 @@ public class ExtendedAccessLogValve extends AccessLogValve {
                         if (first) {
                             first = false;
                         } else {
-                            buffer.append(",");
+                            buffer.append(',');
                         }
                         buffer.append(iter.next());
                     }
@@ -347,7 +347,7 @@ public class ExtendedAccessLogValve extends AccessLogValve {
                 }
                 return ;
             }
-            buf.append("-");
+            buf.append('-');
         }
     }
 
diff --git a/java/org/apache/catalina/valves/StuckThreadDetectionValve.java b/java/org/apache/catalina/valves/StuckThreadDetectionValve.java
index 3bd96ca..d7105cc 100644
--- a/java/org/apache/catalina/valves/StuckThreadDetectionValve.java
+++ b/java/org/apache/catalina/valves/StuckThreadDetectionValve.java
@@ -195,7 +195,7 @@ public class StuckThreadDetectionValve extends ValveBase {
         Long key = Long.valueOf(Thread.currentThread().getId());
         StringBuffer requestUrl = request.getRequestURL();
         if(request.getQueryString()!=null) {
-            requestUrl.append("?");
+            requestUrl.append('?');
             requestUrl.append(request.getQueryString());
         }
         MonitoredThread monitoredThread = new MonitoredThread(Thread.currentThread(),
diff --git a/java/org/apache/catalina/valves/rewrite/RewriteValve.java b/java/org/apache/catalina/valves/rewrite/RewriteValve.java
index 98ba57a..9c76061 100644
--- a/java/org/apache/catalina/valves/rewrite/RewriteValve.java
+++ b/java/org/apache/catalina/valves/rewrite/RewriteValve.java
@@ -193,7 +193,7 @@ public class RewriteValve extends ValveBase {
     }
 
     public String getConfiguration() {
-        StringBuffer buffer = new StringBuffer();
+        StringBuilder buffer = new StringBuilder();
         for (String mapConfiguration : mapsConfiguration) {
             buffer.append(mapConfiguration).append("\r\n");
         }
@@ -373,8 +373,8 @@ public class RewriteValve extends ValveBase {
                         urlStringDecoded = urlStringDecoded.substring(0, index);
                     }
 
-                    StringBuffer urlStringEncoded =
-                            new StringBuffer(URLEncoder.DEFAULT.encode(urlStringDecoded, uriCharset));
+                    StringBuilder urlStringEncoded =
+                            new StringBuilder(URLEncoder.DEFAULT.encode(urlStringDecoded, uriCharset));
                     if (!qsd && originalQueryStringEncoded != null
                             && originalQueryStringEncoded.length() > 0) {
                         if (rewrittenQueryStringDecoded == null) {
diff --git a/java/org/apache/catalina/valves/rewrite/Substitution.java b/java/org/apache/catalina/valves/rewrite/Substitution.java
index 121fc1e..3470810 100644
--- a/java/org/apache/catalina/valves/rewrite/Substitution.java
+++ b/java/org/apache/catalina/valves/rewrite/Substitution.java
@@ -314,7 +314,7 @@ public class Substitution {
     }
 
     private String evaluateSubstitution(SubstitutionElement[] elements, Matcher rule, Matcher cond, Resolver resolver) {
-        StringBuffer buf = new StringBuffer();
+        StringBuilder buf = new StringBuilder();
         for (SubstitutionElement element : elements) {
             buf.append(element.evaluate(rule, cond, resolver));
         }
diff --git a/java/org/apache/coyote/ajp/AjpMessage.java b/java/org/apache/coyote/ajp/AjpMessage.java
index dc6a6f4..9c93a59 100644
--- a/java/org/apache/coyote/ajp/AjpMessage.java
+++ b/java/org/apache/coyote/ajp/AjpMessage.java
@@ -407,7 +407,7 @@ public class AjpMessage {
             if (!Character.isISOControl((char) buf[i])) {
                 sb.append(Character.valueOf((char) buf[i]));
             } else {
-                sb.append(".");
+                sb.append('.');
             }
         }
         return sb.toString();
diff --git a/java/org/apache/jasper/compiler/Generator.java b/java/org/apache/jasper/compiler/Generator.java
index a70d5d5..3feb48d 100644
--- a/java/org/apache/jasper/compiler/Generator.java
+++ b/java/org/apache/jasper/compiler/Generator.java
@@ -3077,7 +3077,7 @@ class Generator {
                         sb.append(".getValue(");
                         sb.append(getJspContextVar());
                         sb.append(".getELContext()");
-                        sb.append(")");
+                        sb.append(')');
                     }
                     attrValue = sb.toString();
                 } else if (attr.isDeferredMethodInput()
diff --git a/java/org/apache/jasper/compiler/PageDataImpl.java b/java/org/apache/jasper/compiler/PageDataImpl.java
index dff1d88..25e3e43 100644
--- a/java/org/apache/jasper/compiler/PageDataImpl.java
+++ b/java/org/apache/jasper/compiler/PageDataImpl.java
@@ -324,15 +324,15 @@ class PageDataImpl extends PageData implements TagConstants {
         @Override
     public void visit(Node.ELExpression n) throws JasperException {
             if (!n.getRoot().isXmlSyntax()) {
-                buf.append("<").append(JSP_TEXT_ACTION);
-                buf.append(" ");
+                buf.append('<').append(JSP_TEXT_ACTION);
+                buf.append(' ');
                 buf.append(jspIdPrefix);
                 buf.append(":id=\"");
                 buf.append(jspId++).append("\">");
             }
             buf.append("${");
             buf.append(Escape.xml(n.getText()));
-            buf.append("}");
+            buf.append('}');
             if (!n.getRoot().isXmlSyntax()) {
                 buf.append(JSP_TEXT_ACTION_END);
             }
@@ -464,7 +464,7 @@ class PageDataImpl extends PageData implements TagConstants {
             Node.Nodes body = n.getBody();
             String text = n.getText();
 
-            buf.append("<").append(n.getQName());
+            buf.append('<').append(n.getQName());
             buf.append("\n");
 
             printAttributes(n, addDefaultNS);
@@ -523,7 +523,7 @@ class PageDataImpl extends PageData implements TagConstants {
                 return;
             }
 
-            buf.append("<").append(n.getQName());
+            buf.append('<').append(n.getQName());
             buf.append("\n");
 
             // append jsp:id
@@ -557,7 +557,7 @@ class PageDataImpl extends PageData implements TagConstants {
                         first = false;
                         buf.append("  import=\"");
                     } else {
-                        buf.append(",");
+                        buf.append(',');
                     }
                     buf.append(JspUtil.getExprInXml(i));
                 }
@@ -576,7 +576,7 @@ class PageDataImpl extends PageData implements TagConstants {
          * ServletResponse.setContentType(), is derived from the pageInfo.
          */
         private void appendPageDirective() {
-            buf.append("<").append(JSP_PAGE_DIRECTIVE_ACTION);
+            buf.append('<').append(JSP_PAGE_DIRECTIVE_ACTION);
             buf.append("\n");
 
             // append jsp:id
@@ -622,7 +622,7 @@ class PageDataImpl extends PageData implements TagConstants {
          * attribute whose value is hard-coded to UTF-8.
          */
         private void appendTagDirective() {
-            buf.append("<").append(JSP_TAG_DIRECTIVE_ACTION);
+            buf.append('<').append(JSP_TAG_DIRECTIVE_ACTION);
             buf.append("\n");
 
             // append jsp:id
@@ -634,7 +634,7 @@ class PageDataImpl extends PageData implements TagConstants {
 
         private void appendText(String text, boolean createJspTextElement) {
             if (createJspTextElement) {
-                buf.append("<").append(JSP_TEXT_ACTION);
+                buf.append('<').append(JSP_TEXT_ACTION);
                 buf.append("\n");
 
                 // append jsp:id
diff --git a/java/org/apache/juli/JdkLoggerFormatter.java b/java/org/apache/juli/JdkLoggerFormatter.java
index 37b5d1a..99b9096 100644
--- a/java/org/apache/juli/JdkLoggerFormatter.java
+++ b/java/org/apache/juli/JdkLoggerFormatter.java
@@ -65,7 +65,7 @@ public class JdkLoggerFormatter extends Formatter {
         buf.append(time);
 
         // pad to 8 to make it more readable
-        for( int i=0; i<8-buf.length(); i++ ) { buf.append(" "); }
+        for( int i=0; i<8-buf.length(); i++ ) { buf.append(' '); }
 
         //      Append a readable representation of the log level.
         switch(level) {
@@ -81,10 +81,10 @@ public class JdkLoggerFormatter extends Formatter {
 
         // Append the name of the log instance if so configured
         buf.append(name);
-        buf.append(" ");
+        buf.append(' ');
 
         // pad to 20 chars
-        for( int i=0; i<8-buf.length(); i++ ) { buf.append(" "); }
+        for( int i=0; i<8-buf.length(); i++ ) { buf.append(' '); }
 
         // Append the message
         buf.append(message);
diff --git a/java/org/apache/naming/AbstractRef.java b/java/org/apache/naming/AbstractRef.java
index 1f53a66..e9a657b 100644
--- a/java/org/apache/naming/AbstractRef.java
+++ b/java/org/apache/naming/AbstractRef.java
@@ -79,9 +79,9 @@ public abstract class AbstractRef extends Reference {
             sb.append(refAddr.getType());
             sb.append(",content=");
             sb.append(refAddr.getContent());
-            sb.append("}");
+            sb.append('}');
         }
-        sb.append("]");
+        sb.append(']');
         return sb.toString();
     }
 }
diff --git a/java/org/apache/tomcat/util/Diagnostics.java b/java/org/apache/tomcat/util/Diagnostics.java
index 674099c..75b41cf 100644
--- a/java/org/apache/tomcat/util/Diagnostics.java
+++ b/java/org/apache/tomcat/util/Diagnostics.java
@@ -426,7 +426,7 @@ public class Diagnostics {
         sb.append(CRLF);
 
         sb.append(requestedSm.getString("diagnostics.threadDumpTitle"));
-        sb.append(" ");
+        sb.append(' ');
         sb.append(runtimeMXBean.getVmName());
         sb.append(" (");
         sb.append(runtimeMXBean.getVmVersion());
diff --git a/java/org/apache/tomcat/util/MultiThrowable.java b/java/org/apache/tomcat/util/MultiThrowable.java
index 5fca54e9..433eb8f 100644
--- a/java/org/apache/tomcat/util/MultiThrowable.java
+++ b/java/org/apache/tomcat/util/MultiThrowable.java
@@ -89,9 +89,9 @@ public class MultiThrowable extends Throwable {
         sb.append(size());
         sb.append(" wrapped Throwables: ");
         for (Throwable t : throwables) {
-            sb.append("[");
+            sb.append('[');
             sb.append(t.getMessage());
-            sb.append("]");
+            sb.append(']');
         }
 
         return sb.toString();
diff --git a/java/org/apache/tomcat/util/bcel/classfile/ArrayElementValue.java b/java/org/apache/tomcat/util/bcel/classfile/ArrayElementValue.java
index f84054f..d5ee725 100644
--- a/java/org/apache/tomcat/util/bcel/classfile/ArrayElementValue.java
+++ b/java/org/apache/tomcat/util/bcel/classfile/ArrayElementValue.java
@@ -36,15 +36,15 @@ public class ArrayElementValue extends ElementValue
     public String stringifyValue()
     {
         final StringBuilder sb = new StringBuilder();
-        sb.append("[");
+        sb.append('[');
         for (int i = 0; i < evalues.length; i++)
         {
             sb.append(evalues[i].stringifyValue());
             if ((i + 1) < evalues.length) {
-                sb.append(",");
+                sb.append(',');
             }
         }
-        sb.append("]");
+        sb.append(']');
         return sb.toString();
     }
 
diff --git a/java/org/apache/tomcat/util/buf/UriUtil.java b/java/org/apache/tomcat/util/buf/UriUtil.java
index fa56150..f88bc9d 100644
--- a/java/org/apache/tomcat/util/buf/UriUtil.java
+++ b/java/org/apache/tomcat/util/buf/UriUtil.java
@@ -46,7 +46,7 @@ public final class UriUtil {
         } else {
             WAR_SEPARATOR = custom + "/";
             PATTERN_CUSTOM = Pattern.compile(Pattern.quote(WAR_SEPARATOR));
-            StringBuffer sb = new StringBuffer(custom.length() * 3);
+            StringBuilder sb = new StringBuilder(custom.length() * 3);
             // Deliberately use the platform's default encoding
             byte[] ba = custom.getBytes();
             for (byte toEncode : ba) {
diff --git a/java/org/apache/tomcat/util/descriptor/web/ApplicationParameter.java b/java/org/apache/tomcat/util/descriptor/web/ApplicationParameter.java
index e280614..bdc7c0f 100644
--- a/java/org/apache/tomcat/util/descriptor/web/ApplicationParameter.java
+++ b/java/org/apache/tomcat/util/descriptor/web/ApplicationParameter.java
@@ -113,7 +113,7 @@ public class ApplicationParameter implements Serializable {
         sb.append(value);
         sb.append(", override=");
         sb.append(override);
-        sb.append("]");
+        sb.append(']');
         return sb.toString();
 
     }
diff --git a/java/org/apache/tomcat/util/descriptor/web/ContextEjb.java b/java/org/apache/tomcat/util/descriptor/web/ContextEjb.java
index a650afe..09dc8e0 100644
--- a/java/org/apache/tomcat/util/descriptor/web/ContextEjb.java
+++ b/java/org/apache/tomcat/util/descriptor/web/ContextEjb.java
@@ -106,7 +106,7 @@ public class ContextEjb extends ResourceBase {
             sb.append(", link=");
             sb.append(link);
         }
-        sb.append("]");
+        sb.append(']');
         return sb.toString();
 
     }
diff --git a/java/org/apache/tomcat/util/descriptor/web/ContextEnvironment.java b/java/org/apache/tomcat/util/descriptor/web/ContextEnvironment.java
index 43d110c..3cbd075 100644
--- a/java/org/apache/tomcat/util/descriptor/web/ContextEnvironment.java
+++ b/java/org/apache/tomcat/util/descriptor/web/ContextEnvironment.java
@@ -87,7 +87,7 @@ public class ContextEnvironment extends ResourceBase {
         }
         sb.append(", override=");
         sb.append(override);
-        sb.append("]");
+        sb.append(']');
         return sb.toString();
 
     }
diff --git a/java/org/apache/tomcat/util/descriptor/web/ContextHandler.java b/java/org/apache/tomcat/util/descriptor/web/ContextHandler.java
index c0ee25c..bbbdd59 100644
--- a/java/org/apache/tomcat/util/descriptor/web/ContextHandler.java
+++ b/java/org/apache/tomcat/util/descriptor/web/ContextHandler.java
@@ -148,7 +148,7 @@ public class ContextHandler extends ResourceBase {
             sb.append(", init-param=");
             sb.append(this.listProperties());
         }
-        sb.append("]");
+        sb.append(']');
         return sb.toString();
     }
 
diff --git a/java/org/apache/tomcat/util/descriptor/web/ContextLocalEjb.java b/java/org/apache/tomcat/util/descriptor/web/ContextLocalEjb.java
index 29e8d5e..c05da4a 100644
--- a/java/org/apache/tomcat/util/descriptor/web/ContextLocalEjb.java
+++ b/java/org/apache/tomcat/util/descriptor/web/ContextLocalEjb.java
@@ -106,7 +106,7 @@ public class ContextLocalEjb extends ResourceBase {
             sb.append(", local=");
             sb.append(local);
         }
-        sb.append("]");
+        sb.append(']');
         return sb.toString();
     }
 
diff --git a/java/org/apache/tomcat/util/descriptor/web/ContextResource.java b/java/org/apache/tomcat/util/descriptor/web/ContextResource.java
index dd3de30..1d2281b 100644
--- a/java/org/apache/tomcat/util/descriptor/web/ContextResource.java
+++ b/java/org/apache/tomcat/util/descriptor/web/ContextResource.java
@@ -129,7 +129,7 @@ public class ContextResource extends ResourceBase {
             sb.append(", scope=");
             sb.append(scope);
         }
-        sb.append("]");
+        sb.append(']');
         return sb.toString();
     }
 
diff --git a/java/org/apache/tomcat/util/descriptor/web/ContextResourceEnvRef.java b/java/org/apache/tomcat/util/descriptor/web/ContextResourceEnvRef.java
index ba3169c..9f4471b 100644
--- a/java/org/apache/tomcat/util/descriptor/web/ContextResourceEnvRef.java
+++ b/java/org/apache/tomcat/util/descriptor/web/ContextResourceEnvRef.java
@@ -63,7 +63,7 @@ public class ContextResourceEnvRef extends ResourceBase {
         }
         sb.append(", override=");
         sb.append(override);
-        sb.append("]");
+        sb.append(']');
         return sb.toString();
     }
 
diff --git a/java/org/apache/tomcat/util/descriptor/web/ContextResourceLink.java b/java/org/apache/tomcat/util/descriptor/web/ContextResourceLink.java
index e50dcf9..67ca79a 100644
--- a/java/org/apache/tomcat/util/descriptor/web/ContextResourceLink.java
+++ b/java/org/apache/tomcat/util/descriptor/web/ContextResourceLink.java
@@ -76,7 +76,7 @@ public class ContextResourceLink extends ResourceBase {
             sb.append(", global=");
             sb.append(getGlobal());
         }
-        sb.append("]");
+        sb.append(']');
         return sb.toString();
     }
 
diff --git a/java/org/apache/tomcat/util/descriptor/web/ContextService.java b/java/org/apache/tomcat/util/descriptor/web/ContextService.java
index cefdc56..ee597b8 100644
--- a/java/org/apache/tomcat/util/descriptor/web/ContextService.java
+++ b/java/org/apache/tomcat/util/descriptor/web/ContextService.java
@@ -258,7 +258,7 @@ public class ContextService extends ResourceBase {
             sb.append(", handler=");
             sb.append(handlers);
         }
-        sb.append("]");
+        sb.append(']');
         return sb.toString();
     }
 
diff --git a/java/org/apache/tomcat/util/descriptor/web/ContextTransaction.java b/java/org/apache/tomcat/util/descriptor/web/ContextTransaction.java
index 5a9e9e0..3707d74 100644
--- a/java/org/apache/tomcat/util/descriptor/web/ContextTransaction.java
+++ b/java/org/apache/tomcat/util/descriptor/web/ContextTransaction.java
@@ -85,7 +85,7 @@ public class ContextTransaction implements Serializable {
     @Override
     public String toString() {
         StringBuilder sb = new StringBuilder("Transaction[");
-        sb.append("]");
+        sb.append(']');
         return sb.toString();
     }
 }
diff --git a/java/org/apache/tomcat/util/descriptor/web/ErrorPage.java b/java/org/apache/tomcat/util/descriptor/web/ErrorPage.java
index bf0920d..69963081 100644
--- a/java/org/apache/tomcat/util/descriptor/web/ErrorPage.java
+++ b/java/org/apache/tomcat/util/descriptor/web/ErrorPage.java
@@ -148,7 +148,7 @@ public class ErrorPage extends XmlEncodingBase implements Serializable {
         }
         sb.append(", location=");
         sb.append(location);
-        sb.append("]");
+        sb.append(']');
         return sb.toString();
     }
 
diff --git a/java/org/apache/tomcat/util/descriptor/web/FilterDef.java b/java/org/apache/tomcat/util/descriptor/web/FilterDef.java
index 30fd247..3a20896 100644
--- a/java/org/apache/tomcat/util/descriptor/web/FilterDef.java
+++ b/java/org/apache/tomcat/util/descriptor/web/FilterDef.java
@@ -197,7 +197,7 @@ public class FilterDef implements Serializable {
         sb.append(this.filterName);
         sb.append(", filterClass=");
         sb.append(this.filterClass);
-        sb.append("]");
+        sb.append(']');
         return sb.toString();
     }
 
diff --git a/java/org/apache/tomcat/util/descriptor/web/FilterMap.java b/java/org/apache/tomcat/util/descriptor/web/FilterMap.java
index 958e98c..a9cf684 100644
--- a/java/org/apache/tomcat/util/descriptor/web/FilterMap.java
+++ b/java/org/apache/tomcat/util/descriptor/web/FilterMap.java
@@ -215,7 +215,7 @@ public class FilterMap extends XmlEncodingBase implements Serializable {
             sb.append(", urlPattern=");
             sb.append(urlPattern);
         }
-        sb.append("]");
+        sb.append(']');
         return sb.toString();
     }
 
diff --git a/java/org/apache/tomcat/util/descriptor/web/LoginConfig.java b/java/org/apache/tomcat/util/descriptor/web/LoginConfig.java
index 053eb80..afe9aa9 100644
--- a/java/org/apache/tomcat/util/descriptor/web/LoginConfig.java
+++ b/java/org/apache/tomcat/util/descriptor/web/LoginConfig.java
@@ -155,7 +155,7 @@ public class LoginConfig extends XmlEncodingBase implements Serializable {
             sb.append(", errorPage=");
             sb.append(errorPage);
         }
-        sb.append("]");
+        sb.append(']');
         return sb.toString();
     }
 
diff --git a/java/org/apache/tomcat/util/descriptor/web/MessageDestination.java b/java/org/apache/tomcat/util/descriptor/web/MessageDestination.java
index be9fcfb..d323a76 100644
--- a/java/org/apache/tomcat/util/descriptor/web/MessageDestination.java
+++ b/java/org/apache/tomcat/util/descriptor/web/MessageDestination.java
@@ -101,7 +101,7 @@ public class MessageDestination extends ResourceBase {
             sb.append(", description=");
             sb.append(getDescription());
         }
-        sb.append("]");
+        sb.append(']');
         return sb.toString();
     }
 
diff --git a/java/org/apache/tomcat/util/descriptor/web/MessageDestinationRef.java b/java/org/apache/tomcat/util/descriptor/web/MessageDestinationRef.java
index 25d9f67..5118898 100644
--- a/java/org/apache/tomcat/util/descriptor/web/MessageDestinationRef.java
+++ b/java/org/apache/tomcat/util/descriptor/web/MessageDestinationRef.java
@@ -86,7 +86,7 @@ public class MessageDestinationRef extends ResourceBase {
             sb.append(", description=");
             sb.append(getDescription());
         }
-        sb.append("]");
+        sb.append(']');
         return sb.toString();
     }
 
diff --git a/java/org/apache/tomcat/util/descriptor/web/SecurityCollection.java b/java/org/apache/tomcat/util/descriptor/web/SecurityCollection.java
index a0c6d15..b3a9b00 100644
--- a/java/org/apache/tomcat/util/descriptor/web/SecurityCollection.java
+++ b/java/org/apache/tomcat/util/descriptor/web/SecurityCollection.java
@@ -386,7 +386,7 @@ public class SecurityCollection extends XmlEncodingBase implements Serializable
             sb.append(", ");
             sb.append(description);
         }
-        sb.append("]");
+        sb.append(']');
         return sb.toString();
     }
 
diff --git a/java/org/apache/tomcat/util/descriptor/web/SecurityConstraint.java b/java/org/apache/tomcat/util/descriptor/web/SecurityConstraint.java
index a3008f8..607652c 100644
--- a/java/org/apache/tomcat/util/descriptor/web/SecurityConstraint.java
+++ b/java/org/apache/tomcat/util/descriptor/web/SecurityConstraint.java
@@ -468,7 +468,7 @@ public class SecurityConstraint extends XmlEncodingBase implements Serializable
                 sb.append(", ");
             sb.append(collections[i].getName());
         }
-        sb.append("]");
+        sb.append(']');
         return sb.toString();
     }
 
diff --git a/java/org/apache/tomcat/util/descriptor/web/SecurityRoleRef.java b/java/org/apache/tomcat/util/descriptor/web/SecurityRoleRef.java
index 360ea7c..92083c2 100644
--- a/java/org/apache/tomcat/util/descriptor/web/SecurityRoleRef.java
+++ b/java/org/apache/tomcat/util/descriptor/web/SecurityRoleRef.java
@@ -79,7 +79,7 @@ public class SecurityRoleRef implements Serializable {
             sb.append(", link=");
             sb.append(link);
         }
-        sb.append("]");
+        sb.append(']');
         return sb.toString();
     }
 
diff --git a/java/org/apache/tomcat/util/descriptor/web/WebRuleSet.java b/java/org/apache/tomcat/util/descriptor/web/WebRuleSet.java
index 132c8d588..237d1c1 100644
--- a/java/org/apache/tomcat/util/descriptor/web/WebRuleSet.java
+++ b/java/org/apache/tomcat/util/descriptor/web/WebRuleSet.java
@@ -1022,7 +1022,7 @@ final class CallMethodMultiRule extends CallMethodRule {
             sb.append(targetOffset);
             sb.append(",stackdepth=");
             sb.append(digester.getCount());
-            sb.append(")");
+            sb.append(')');
             throw new org.xml.sax.SAXException(sb.toString());
         }
 
diff --git a/java/org/apache/tomcat/util/descriptor/web/WebXml.java b/java/org/apache/tomcat/util/descriptor/web/WebXml.java
index d13a439..6dfa5f5 100644
--- a/java/org/apache/tomcat/util/descriptor/web/WebXml.java
+++ b/java/org/apache/tomcat/util/descriptor/web/WebXml.java
@@ -760,7 +760,7 @@ public class WebXml extends XmlEncodingBase implements DocumentProperties.Charse
             sb.append("\"http://www.w3.org/2001/XMLSchema-instance\"\n");
             sb.append("         xsi:schemaLocation=\"");
             sb.append(javaeeNamespace);
-            sb.append(" ");
+            sb.append(' ');
             sb.append(webXmlSchemaLocation);
             sb.append("\"\n");
             sb.append("         version=\"");
diff --git a/java/org/apache/tomcat/util/digester/CallMethodRule.java b/java/org/apache/tomcat/util/digester/CallMethodRule.java
index 83aaf57..9310011 100644
--- a/java/org/apache/tomcat/util/digester/CallMethodRule.java
+++ b/java/org/apache/tomcat/util/digester/CallMethodRule.java
@@ -348,7 +348,7 @@ public class CallMethodRule extends Rule {
             sb.append(targetOffset);
             sb.append(",stackdepth=");
             sb.append(digester.getCount());
-            sb.append(")");
+            sb.append(')');
             throw new org.xml.sax.SAXException(sb.toString());
         }
 
@@ -358,26 +358,26 @@ public class CallMethodRule extends Rule {
             sb.append(digester.match);
             sb.append("} Call ");
             sb.append(target.getClass().getName());
-            sb.append(".");
+            sb.append('.');
             sb.append(methodName);
-            sb.append("(");
+            sb.append('(');
             for (int i = 0; i < paramValues.length; i++) {
                 if (i > 0) {
-                    sb.append(",");
+                    sb.append(',');
                 }
                 if (paramValues[i] == null) {
                     sb.append("null");
                 } else {
                     sb.append(paramValues[i].toString());
                 }
-                sb.append("/");
+                sb.append('/');
                 if (paramTypes[i] == null) {
                     sb.append("null");
                 } else {
                     sb.append(paramTypes[i].getName());
                 }
             }
-            sb.append(")");
+            sb.append(')');
             digester.log.debug(sb.toString());
         }
         Object result = IntrospectionUtils.callMethodN(target, methodName,
@@ -386,11 +386,11 @@ public class CallMethodRule extends Rule {
 
         StringBuilder code = digester.getGeneratedCode();
         if (code != null) {
-            code.append(digester.toVariableName(target)).append(".").append(methodName);
-            code.append("(");
+            code.append(digester.toVariableName(target)).append('.').append(methodName);
+            code.append('(');
             for (int i = 0; i < paramValues.length; i++) {
                 if (i > 0) {
-                    code.append(",");
+                    code.append(',');
                 }
                 if (bodyText != null) {
                     code.append("\"").append(bodyText).append("\"");
@@ -443,8 +443,8 @@ public class CallMethodRule extends Rule {
                 sb.append(paramTypes[i].getName());
             }
         }
-        sb.append("}");
-        sb.append("]");
+        sb.append('}');
+        sb.append(']');
         return sb.toString();
     }
-}
\ No newline at end of file
+}
diff --git a/java/org/apache/tomcat/util/digester/CallParamRule.java b/java/org/apache/tomcat/util/digester/CallParamRule.java
index a952f3a..799318c 100644
--- a/java/org/apache/tomcat/util/digester/CallParamRule.java
+++ b/java/org/apache/tomcat/util/digester/CallParamRule.java
@@ -198,7 +198,7 @@ public class CallParamRule extends Rule {
         sb.append(attributeName);
         sb.append(", from stack=");
         sb.append(fromStack);
-        sb.append("]");
+        sb.append(']');
         return sb.toString();
     }
 
diff --git a/java/org/apache/tomcat/util/digester/FactoryCreateRule.java b/java/org/apache/tomcat/util/digester/FactoryCreateRule.java
index 8d1e3d7..9cdd909 100644
--- a/java/org/apache/tomcat/util/digester/FactoryCreateRule.java
+++ b/java/org/apache/tomcat/util/digester/FactoryCreateRule.java
@@ -173,7 +173,7 @@ public class FactoryCreateRule extends Rule {
             sb.append("creationFactory=");
             sb.append(creationFactory);
         }
-        sb.append("]");
+        sb.append(']');
         return sb.toString();
     }
 }
diff --git a/java/org/apache/tomcat/util/digester/ObjectCreateRule.java b/java/org/apache/tomcat/util/digester/ObjectCreateRule.java
index ffcf4ba..cfa8ef6 100644
--- a/java/org/apache/tomcat/util/digester/ObjectCreateRule.java
+++ b/java/org/apache/tomcat/util/digester/ObjectCreateRule.java
@@ -108,7 +108,7 @@ public class ObjectCreateRule extends Rule {
         StringBuilder code = digester.getGeneratedCode();
         if (code != null) {
             code.append(System.lineSeparator());
-            code.append(realClassName).append(" ").append(digester.toVariableName(instance)).append(" = new ");
+            code.append(realClassName).append(' ').append(digester.toVariableName(instance)).append(" = new ");
             code.append(realClassName).append("();").append(System.lineSeparator());
         }
     }
@@ -167,7 +167,7 @@ public class ObjectCreateRule extends Rule {
         sb.append(className);
         sb.append(", attributeName=");
         sb.append(attributeName);
-        sb.append("]");
+        sb.append(']');
         return sb.toString();
     }
 
diff --git a/java/org/apache/tomcat/util/digester/SetNextRule.java b/java/org/apache/tomcat/util/digester/SetNextRule.java
index 1fa14f3..21e065c 100644
--- a/java/org/apache/tomcat/util/digester/SetNextRule.java
+++ b/java/org/apache/tomcat/util/digester/SetNextRule.java
@@ -147,8 +147,8 @@ public class SetNextRule extends Rule {
 
         StringBuilder code = digester.getGeneratedCode();
         if (code != null) {
-            code.append(digester.toVariableName(parent)).append(".");
-            code.append(methodName).append("(").append(digester.toVariableName(child)).append(");");
+            code.append(digester.toVariableName(parent)).append('.');
+            code.append(methodName).append('(').append(digester.toVariableName(child)).append(");");
             code.append(System.lineSeparator());
         }
     }
@@ -164,7 +164,7 @@ public class SetNextRule extends Rule {
         sb.append(methodName);
         sb.append(", paramType=");
         sb.append(paramType);
-        sb.append("]");
+        sb.append(']');
         return sb.toString();
     }
 
diff --git a/java/org/apache/tomcat/util/digester/SetPropertiesRule.java b/java/org/apache/tomcat/util/digester/SetPropertiesRule.java
index 284bc2f..929af7e 100644
--- a/java/org/apache/tomcat/util/digester/SetPropertiesRule.java
+++ b/java/org/apache/tomcat/util/digester/SetPropertiesRule.java
@@ -107,7 +107,7 @@ public class SetPropertiesRule extends Rule {
                     }
                 } else {
                     if (code != null) {
-                        code.append(variableName).append(".").append(actualMethod).append(";");
+                        code.append(variableName).append(".").append(actualMethod).append(';');
                         code.append(System.lineSeparator());
                     }
                 }
@@ -132,7 +132,7 @@ public class SetPropertiesRule extends Rule {
     @Override
     public String toString() {
         StringBuilder sb = new StringBuilder("SetPropertiesRule[");
-        sb.append("]");
+        sb.append(']');
         return sb.toString();
     }
 }
diff --git a/java/org/apache/tomcat/util/http/LegacyCookieProcessor.java b/java/org/apache/tomcat/util/http/LegacyCookieProcessor.java
index ea22385..a3fc73b 100644
--- a/java/org/apache/tomcat/util/http/LegacyCookieProcessor.java
+++ b/java/org/apache/tomcat/util/http/LegacyCookieProcessor.java
@@ -269,7 +269,7 @@ public final class LegacyCookieProcessor extends CookieProcessorBase {
 
         // Just use the name supplied in the Cookie
         buf.append(cookie.getName());
-        buf.append("=");
+        buf.append('=');
 
         // Value
         maybeQuote(buf, value, version);
diff --git a/java/org/apache/tomcat/util/http/fileupload/FileUploadBase.java b/java/org/apache/tomcat/util/http/fileupload/FileUploadBase.java
index 4a68be2..96b2508 100644
--- a/java/org/apache/tomcat/util/http/fileupload/FileUploadBase.java
+++ b/java/org/apache/tomcat/util/http/fileupload/FileUploadBase.java
@@ -491,7 +491,7 @@ public abstract class FileUploadBase {
                 }
                 // Continuation line found
                 end = parseEndOfLine(headerPart, nonWs);
-                header.append(" ").append(headerPart.substring(nonWs, end));
+                header.append(' ').append(headerPart.substring(nonWs, end));
                 start = end + 2;
             }
             parseHeaderLine(headers, header.toString());
diff --git a/java/org/apache/tomcat/util/modeler/ManagedBean.java b/java/org/apache/tomcat/util/modeler/ManagedBean.java
index 31e3d20..6215200 100644
--- a/java/org/apache/tomcat/util/modeler/ManagedBean.java
+++ b/java/org/apache/tomcat/util/modeler/ManagedBean.java
@@ -419,7 +419,7 @@ public class ManagedBean implements java.io.Serializable {
         }
         sb.append(", type=");
         sb.append(type);
-        sb.append("]");
+        sb.append(']');
         return sb.toString();
 
     }
diff --git a/java/org/apache/tomcat/util/modeler/NotificationInfo.java b/java/org/apache/tomcat/util/modeler/NotificationInfo.java
index 19159cf..5a660b5 100644
--- a/java/org/apache/tomcat/util/modeler/NotificationInfo.java
+++ b/java/org/apache/tomcat/util/modeler/NotificationInfo.java
@@ -150,7 +150,7 @@ public class NotificationInfo extends FeatureInfo {
         } finally {
             readLock.unlock();
         }
-        sb.append("]");
+        sb.append(']');
         return sb.toString();
     }
 }
diff --git a/java/org/apache/tomcat/util/net/AprEndpoint.java b/java/org/apache/tomcat/util/net/AprEndpoint.java
index 3996087..8f1a7eb 100644
--- a/java/org/apache/tomcat/util/net/AprEndpoint.java
+++ b/java/org/apache/tomcat/util/net/AprEndpoint.java
@@ -1245,15 +1245,15 @@ public class AprEndpoint extends AbstractEndpoint<Long,Long> implements SNICallB
          */
         @Override
         public String toString() {
-            StringBuffer buf = new StringBuffer();
+            StringBuilder buf = new StringBuilder();
             buf.append("Poller");
             long[] res = new long[pollerSize * 2];
             int count = Poll.pollset(aprPoller, res);
             buf.append(" [ ");
             for (int j = 0; j < count; j++) {
-                buf.append(desc[2*j+1]).append(" ");
+                buf.append(desc[2*j+1]).append(' ');
             }
-            buf.append("]");
+            buf.append(']');
             return buf.toString();
         }
 
diff --git a/java/org/apache/tomcat/websocket/DigestAuthenticator.java b/java/org/apache/tomcat/websocket/DigestAuthenticator.java
index 021489f..a343159 100644
--- a/java/org/apache/tomcat/websocket/DigestAuthenticator.java
+++ b/java/org/apache/tomcat/websocket/DigestAuthenticator.java
@@ -116,19 +116,19 @@ public class DigestAuthenticator extends Authenticator {
         String A2 = "GET:" + requestUri;
 
         preDigest.append(encodeMD5(A1));
-        preDigest.append(":");
+        preDigest.append(':');
         preDigest.append(nonce);
 
         if (qop.toLowerCase().contains("auth")) {
-            preDigest.append(":");
+            preDigest.append(':');
             preDigest.append(String.format("%08X", Integer.valueOf(nonceCount)));
-            preDigest.append(":");
+            preDigest.append(':');
             preDigest.append(String.valueOf(cNonce));
-            preDigest.append(":");
+            preDigest.append(':');
             preDigest.append(qop);
         }
 
-        preDigest.append(":");
+        preDigest.append(':');
         preDigest.append(encodeMD5(A2));
 
         return encodeMD5(preDigest.toString());
diff --git a/java/org/apache/tomcat/websocket/server/WsHandshakeRequest.java b/java/org/apache/tomcat/websocket/server/WsHandshakeRequest.java
index a10cb8c..712a2e9 100644
--- a/java/org/apache/tomcat/websocket/server/WsHandshakeRequest.java
+++ b/java/org/apache/tomcat/websocket/server/WsHandshakeRequest.java
@@ -144,7 +144,7 @@ public class WsHandshakeRequest implements HandshakeRequest {
      */
     private static URI buildRequestUri(HttpServletRequest req) {
 
-        StringBuffer uri = new StringBuffer();
+        StringBuilder uri = new StringBuilder();
         String scheme = req.getScheme();
         int port = req.getServerPort();
         if (port < 0) {
@@ -174,7 +174,7 @@ public class WsHandshakeRequest implements HandshakeRequest {
         uri.append(req.getRequestURI());
 
         if (req.getQueryString() != null) {
-            uri.append("?");
+            uri.append('?');
             uri.append(req.getQueryString());
         }
 


---------------------------------------------------------------------
To unsubscribe, e-mail: [hidden email]
For additional commands, e-mail: [hidden email]

Reply | Threaded
Open this post in threaded view
|

Re: [tomcat] branch master updated: Use StringBuilder instead of StringBuffer

Christopher Schultz-2
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA256

Martin,

On 7/6/20 03:09, [hidden email] wrote:

> diff --git
> a/java/org/apache/catalina/connector/CoyotePrincipal.java
> b/java/org/apache/catalina/connector/CoyotePrincipal.java index
> 1ae5608..93d7c02 100644 ---
> a/java/org/apache/catalina/connector/CoyotePrincipal.java +++
> b/java/org/apache/catalina/connector/CoyotePrincipal.java @@ -64,7
> +64,7 @@ public class CoyotePrincipal implements Principal,
> Serializable { public String toString() { StringBuilder sb = new
> StringBuilder("CoyotePrincipal["); sb.append(this.name); -
> sb.append("]"); +        sb.append(']'); return sb.toString(); }

Might I suggest further improvements?

Step 1:

      public String toString() {
          return new StringBuilder("CoyotePrincipal[")
          .append(this.name);
          .append(']');
          .toString();

It turns out that the generated bytecode is something like 2/3 as long
as the sb.append(); sb.append(); sb.append(); code. JIT probably does
the same thing eventually, but why not help it out?

Step 2:

      public String toString() {
          return "CoyotePrincipal[" + this.name + ']';
      }

This has a few advantages:

1. It's dead easy to read

2. The compiler makes the best decision as to how to perform the
concatenation

In very old versions of Java, you'll get StringBuffer concatenation as
the pre-commit version. Later versions get you StringBuilder as
post-commit version. Post 9.x-versions get you a call to
StringConcatFactory.makeConcatWithConstants which is presumably even
more efficient.

I understand that this was supposed to be a small patch, but I think
further improvements are possible in many cases like this one.

Thanks,
- -chris
-----BEGIN PGP SIGNATURE-----
Comment: Using GnuPG with Thunderbird - https://www.enigmail.net/

iQIzBAEBCAAdFiEEMmKgYcQvxMe7tcJcHPApP6U8pFgFAl8DMT8ACgkQHPApP6U8
pFgUtA/+OoHnIgHBLoIOXqP5t10g/dBFxGrIpOUOe1MvIhWMdObcNIlZmnM1vv0Z
xCRYXxGCj20xm4P/NEzvRlEPWfd0uvoZczr34JVPlgOWUBJeRHmLQ+KlGdCeuuKk
cmxV4ZXZSt8bzVMufQ+N2RPOCGUvti2kin0CSj9BlygKuTAMuXgwVcyEo7XvLf3z
153dHylBL3ka5jo2lR4vYlj8U6PvzoZuLj3NAnrRZP3YttbQKimhXDcOg7zkeVP+
GFINDBE+fux+s5P38vqRLqzA4JEDFfjsKzT4JV21BrSbxhdUbXyYE4RMhW+izKB8
B/SJhBtEN1huED3GkZbg/DN0nYgY4vVeoHz4kdal1E5uVybG5SLj6xoz6tkRsayB
pOHguW1ds8NLPJwHBEATq6YQOXGfqECbW+iWuP54F7eBzo57CiZWsnQPalpSo9pn
mdBRbcfyI7z9vJFaiGCpudKGKK5+F1VFj6KELxZP7nAO0Lyhwapsai9TzLXLOTk1
8ReS5GENoZDrzrb3Gn/YCmdYAxdED9ejjkiY5qVjX3ZXWXaeytcz1h3bY2opV4Ks
a+tahArWqI1t44cemejJuiXFZB0xrDjji6pnd3ZqZ4vG1TREKxK2hdLjuwP3vaw9
fqt4d3E596rPtqF2e0aJLGfW+3iJ2r67c7DP9ARHMAdadMIi23U=
=N+0c
-----END PGP SIGNATURE-----

---------------------------------------------------------------------
To unsubscribe, e-mail: [hidden email]
For additional commands, e-mail: [hidden email]

Reply | Threaded
Open this post in threaded view
|

Re: [tomcat] branch master updated: Use StringBuilder instead of StringBuffer

Martin Grigorov
Hi Chris,

On Mon, Jul 6, 2020 at 5:12 PM Christopher Schultz <[hidden email]> wrote:
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA256

Martin,

On 7/6/20 03:09, [hidden email] wrote:
> diff --git
> a/java/org/apache/catalina/connector/CoyotePrincipal.java
> b/java/org/apache/catalina/connector/CoyotePrincipal.java index
> 1ae5608..93d7c02 100644 ---
> a/java/org/apache/catalina/connector/CoyotePrincipal.java +++
> b/java/org/apache/catalina/connector/CoyotePrincipal.java @@ -64,7
> +64,7 @@ public class CoyotePrincipal implements Principal,
> Serializable { public String toString() { StringBuilder sb = new
> StringBuilder("CoyotePrincipal["); sb.append(this.name); -
> sb.append("]"); +        sb.append(']'); return sb.toString(); }

Might I suggest further improvements?

Step 1:

      public String toString() {
          return new StringBuilder("CoyotePrincipal[")
          .append(this.name);
          .append(']');
          .toString();

It turns out that the generated bytecode is something like 2/3 as long
as the sb.append(); sb.append(); sb.append(); code. JIT probably does
the same thing eventually, but why not help it out?

Step 2:

      public String toString() {
          return "CoyotePrincipal[" + this.name + ']';
      }

This has a few advantages:

1. It's dead easy to read

2. The compiler makes the best decision as to how to perform the
concatenation

In very old versions of Java, you'll get StringBuffer concatenation as
the pre-commit version. Later versions get you StringBuilder as
post-commit version. Post 9.x-versions get you a call to
StringConcatFactory.makeConcatWithConstants which is presumably even
more efficient.

I understand that this was supposed to be a small patch, but I think
further improvements are possible in many cases like this one.

Agreed!

Martin
 

Thanks,
- -chris
-----BEGIN PGP SIGNATURE-----
Comment: Using GnuPG with Thunderbird - https://www.enigmail.net/

iQIzBAEBCAAdFiEEMmKgYcQvxMe7tcJcHPApP6U8pFgFAl8DMT8ACgkQHPApP6U8
pFgUtA/+OoHnIgHBLoIOXqP5t10g/dBFxGrIpOUOe1MvIhWMdObcNIlZmnM1vv0Z
xCRYXxGCj20xm4P/NEzvRlEPWfd0uvoZczr34JVPlgOWUBJeRHmLQ+KlGdCeuuKk
cmxV4ZXZSt8bzVMufQ+N2RPOCGUvti2kin0CSj9BlygKuTAMuXgwVcyEo7XvLf3z
153dHylBL3ka5jo2lR4vYlj8U6PvzoZuLj3NAnrRZP3YttbQKimhXDcOg7zkeVP+
GFINDBE+fux+s5P38vqRLqzA4JEDFfjsKzT4JV21BrSbxhdUbXyYE4RMhW+izKB8
B/SJhBtEN1huED3GkZbg/DN0nYgY4vVeoHz4kdal1E5uVybG5SLj6xoz6tkRsayB
pOHguW1ds8NLPJwHBEATq6YQOXGfqECbW+iWuP54F7eBzo57CiZWsnQPalpSo9pn
mdBRbcfyI7z9vJFaiGCpudKGKK5+F1VFj6KELxZP7nAO0Lyhwapsai9TzLXLOTk1
8ReS5GENoZDrzrb3Gn/YCmdYAxdED9ejjkiY5qVjX3ZXWXaeytcz1h3bY2opV4Ks
a+tahArWqI1t44cemejJuiXFZB0xrDjji6pnd3ZqZ4vG1TREKxK2hdLjuwP3vaw9
fqt4d3E596rPtqF2e0aJLGfW+3iJ2r67c7DP9ARHMAdadMIi23U=
=N+0c
-----END PGP SIGNATURE-----

---------------------------------------------------------------------
To unsubscribe, e-mail: [hidden email]
For additional commands, e-mail: [hidden email]