tomcat-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ma...@apache.org
Subject svn commit: r832025 - in /tomcat/trunk/java/org/apache/catalina/valves: AccessLogValve.java ErrorReportValve.java ExtendedAccessLogValve.java ValveBase.java
Date Mon, 02 Nov 2009 18:39:31 GMT
Author: markt
Date: Mon Nov  2 18:39:31 2009
New Revision: 832025

URL: http://svn.apache.org/viewvc?rev=832025&view=rev
Log:
StringBuffer -> StringBuilder for o.a.c.valves

Modified:
    tomcat/trunk/java/org/apache/catalina/valves/AccessLogValve.java
    tomcat/trunk/java/org/apache/catalina/valves/ErrorReportValve.java
    tomcat/trunk/java/org/apache/catalina/valves/ExtendedAccessLogValve.java
    tomcat/trunk/java/org/apache/catalina/valves/ValveBase.java

Modified: tomcat/trunk/java/org/apache/catalina/valves/AccessLogValve.java
URL: http://svn.apache.org/viewvc/tomcat/trunk/java/org/apache/catalina/valves/AccessLogValve.java?rev=832025&r1=832024&r2=832025&view=diff
==============================================================================
--- tomcat/trunk/java/org/apache/catalina/valves/AccessLogValve.java (original)
+++ tomcat/trunk/java/org/apache/catalina/valves/AccessLogValve.java Mon Nov  2 18:39:31 2009
@@ -569,7 +569,7 @@
             }
     
             Date date = getDate();
-            StringBuffer result = new StringBuffer(128);
+            StringBuilder result = new StringBuilder(128);
     
             for (int i = 0; i < logElements.length; i++) {
                 logElements[i].addElement(result, date, request, response, time);
@@ -772,7 +772,7 @@
     
     
     private String calculateTimeZoneOffset(long offset) {
-        StringBuffer tz = new StringBuffer();
+        StringBuilder tz = new StringBuilder();
         if ((offset < 0)) {
             tz.append("-");
             offset = -offset;
@@ -883,7 +883,7 @@
      * AccessLogElement writes the partial message into the buffer.
      */
     protected interface AccessLogElement {
-        public void addElement(StringBuffer buf, Date date, Request request,
+        public void addElement(StringBuilder buf, Date date, Request request,
                 Response response, long time);
 
     }
@@ -892,7 +892,7 @@
      * write thread name - %I
      */
     protected class ThreadNameElement implements AccessLogElement {
-        public void addElement(StringBuffer buf, Date date, Request request,
+        public void addElement(StringBuilder buf, Date date, Request request,
                 Response response, long time) {
             RequestInfo info = request.getCoyoteRequest().getRequestProcessor();
             if(info != null) {
@@ -920,7 +920,7 @@
             LOCAL_ADDR_VALUE = init;
         }
         
-        public void addElement(StringBuffer buf, Date date, Request request,
+        public void addElement(StringBuilder buf, Date date, Request request,
                 Response response, long time) {
             buf.append(LOCAL_ADDR_VALUE);
         }
@@ -930,7 +930,7 @@
      * write remote IP address - %a
      */
     protected class RemoteAddrElement implements AccessLogElement {
-        public void addElement(StringBuffer buf, Date date, Request request,
+        public void addElement(StringBuilder buf, Date date, Request request,
                 Response response, long time) {
             buf.append(request.getRemoteAddr());
         }
@@ -940,7 +940,7 @@
      * write remote host name - %h
      */
     protected class HostElement implements AccessLogElement {
-        public void addElement(StringBuffer buf, Date date, Request request,
+        public void addElement(StringBuilder buf, Date date, Request request,
                 Response response, long time) {
             buf.append(request.getRemoteHost());
         }
@@ -950,7 +950,7 @@
      * write remote logical username from identd (always returns '-') - %l
      */
     protected class LogicalUserNameElement implements AccessLogElement {
-        public void addElement(StringBuffer buf, Date date, Request request,
+        public void addElement(StringBuilder buf, Date date, Request request,
                 Response response, long time) {
             buf.append('-');
         }
@@ -960,7 +960,7 @@
      * write request protocol - %H
      */
     protected class ProtocolElement implements AccessLogElement {
-        public void addElement(StringBuffer buf, Date date, Request request,
+        public void addElement(StringBuilder buf, Date date, Request request,
                 Response response, long time) {
             buf.append(request.getProtocol());
         }
@@ -970,7 +970,7 @@
      * write remote user that was authenticated (if any), else '-' - %u
      */
     protected class UserElement implements AccessLogElement {
-        public void addElement(StringBuffer buf, Date date, Request request,
+        public void addElement(StringBuilder buf, Date date, Request request,
                 Response response, long time) {
             if (request != null) {
                 String value = request.getRemoteUser();
@@ -993,11 +993,11 @@
         
 
 
-        public void addElement(StringBuffer buf, Date date, Request request,
+        public void addElement(StringBuilder buf, Date date, Request request,
                 Response response, long time) {
             AccessDateStruct struct = currentDateStruct.get();
             if (struct.currentDateString == null) {
-                StringBuffer current = new StringBuffer(32);
+                StringBuilder current = new StringBuilder(32);
                 current.append('[');
                 current.append(struct.dayFormatter.format(date));
                 current.append('/');
@@ -1019,7 +1019,7 @@
      * write first line of the request (method and request URI) - %r
      */
     protected class RequestElement implements AccessLogElement {
-        public void addElement(StringBuffer buf, Date date, Request request,
+        public void addElement(StringBuilder buf, Date date, Request request,
                 Response response, long time) {
             if (request != null) {
                 buf.append(request.getMethod());
@@ -1041,7 +1041,7 @@
      * write HTTP status code of the response - %s
      */
     protected class HttpStatusCodeElement implements AccessLogElement {
-        public void addElement(StringBuffer buf, Date date, Request request,
+        public void addElement(StringBuilder buf, Date date, Request request,
                 Response response, long time) {
             if (response != null) {
                 buf.append(response.getStatus());
@@ -1055,7 +1055,7 @@
      * write local port on which this request was received - %p
      */
     protected class LocalPortElement implements AccessLogElement {
-        public void addElement(StringBuffer buf, Date date, Request request,
+        public void addElement(StringBuilder buf, Date date, Request request,
                 Response response, long time) {
             buf.append(request.getServerPort());
         }
@@ -1074,7 +1074,7 @@
             this.conversion = conversion;
         }
 
-        public void addElement(StringBuffer buf, Date date, Request request,
+        public void addElement(StringBuilder buf, Date date, Request request,
                 Response response, long time) {
             long length = response.getContentCountLong() ;
             if (length <= 0 && conversion) {
@@ -1089,7 +1089,7 @@
      * write request method (GET, POST, etc.) - %m
      */
     protected class MethodElement implements AccessLogElement {
-        public void addElement(StringBuffer buf, Date date, Request request,
+        public void addElement(StringBuilder buf, Date date, Request request,
                 Response response, long time) {
             if (request != null) {
                 buf.append(request.getMethod());
@@ -1111,7 +1111,7 @@
             this.millis = millis;
         }
 
-        public void addElement(StringBuffer buf, Date date, Request request,
+        public void addElement(StringBuilder buf, Date date, Request request,
                 Response response, long time) {
             if (millis) {
                 buf.append(time);
@@ -1132,7 +1132,7 @@
      * write Query string (prepended with a '?' if it exists) - %q
      */
     protected class QueryElement implements AccessLogElement {
-        public void addElement(StringBuffer buf, Date date, Request request,
+        public void addElement(StringBuilder buf, Date date, Request request,
                 Response response, long time) {
             String query = null;
             if (request != null)
@@ -1148,7 +1148,7 @@
      * write user session ID - %S
      */
     protected class SessionIdElement implements AccessLogElement {
-        public void addElement(StringBuffer buf, Date date, Request request,
+        public void addElement(StringBuilder buf, Date date, Request request,
                 Response response, long time) {
             if (request != null) {
                 if (request.getSession(false) != null) {
@@ -1167,7 +1167,7 @@
      * write requested URL path - %U
      */
     protected class RequestURIElement implements AccessLogElement {
-        public void addElement(StringBuffer buf, Date date, Request request,
+        public void addElement(StringBuilder buf, Date date, Request request,
                 Response response, long time) {
             if (request != null) {
                 buf.append(request.getRequestURI());
@@ -1181,7 +1181,7 @@
      * write local server name - %v
      */
     protected class LocalServerNameElement implements AccessLogElement {
-        public void addElement(StringBuffer buf, Date date, Request request,
+        public void addElement(StringBuilder buf, Date date, Request request,
                 Response response, long time) {
             buf.append(request.getServerName());
         }
@@ -1197,7 +1197,7 @@
             this.str = str;
         }
 
-        public void addElement(StringBuffer buf, Date date, Request request,
+        public void addElement(StringBuilder buf, Date date, Request request,
                 Response response, long time) {
             buf.append(str);
         }
@@ -1213,7 +1213,7 @@
             this.header = header;
         }
 
-        public void addElement(StringBuffer buf, Date date, Request request,
+        public void addElement(StringBuilder buf, Date date, Request request,
                 Response response, long time) {
             String value = request.getHeader(header);
             if (value == null) {
@@ -1234,7 +1234,7 @@
             this.header = header;
         }
 
-        public void addElement(StringBuffer buf, Date date, Request request,
+        public void addElement(StringBuilder buf, Date date, Request request,
                 Response response, long time) {
             String value = "-";
             Cookie[] c = request.getCookies();
@@ -1260,7 +1260,7 @@
             this.header = header;
         }
         
-        public void addElement(StringBuffer buf, Date date, Request request,
+        public void addElement(StringBuilder buf, Date date, Request request,
                 Response response, long time) {
            if (null != response) {
                 Iterator<String> iter = response.getHeaders(header).iterator();
@@ -1287,7 +1287,7 @@
             this.header = header;
         }
 
-        public void addElement(StringBuffer buf, Date date, Request request,
+        public void addElement(StringBuilder buf, Date date, Request request,
                 Response response, long time) {
             Object value = null;
             if (request != null) {
@@ -1317,7 +1317,7 @@
             this.header = header;
         }
 
-        public void addElement(StringBuffer buf, Date date, Request request,
+        public void addElement(StringBuilder buf, Date date, Request request,
                 Response response, long time) {
             Object value = null;
             if (null != request) {
@@ -1348,7 +1348,7 @@
     protected AccessLogElement[] createLogElements() {
         List<AccessLogElement> list = new ArrayList<AccessLogElement>();
         boolean replace = false;
-        StringBuffer buf = new StringBuffer();
+        StringBuilder buf = new StringBuilder();
         for (int i = 0; i < pattern.length(); i++) {
             char ch = pattern.charAt(i);
             if (replace) {
@@ -1357,7 +1357,7 @@
                  * not enounter a closing } - then I ignore the {
                  */
                 if ('{' == ch) {
-                    StringBuffer name = new StringBuffer();
+                    StringBuilder name = new StringBuilder();
                     int j = i + 1;
                     for (; j < pattern.length() && '}' != pattern.charAt(j); j++)
{
                         name.append(pattern.charAt(j));
@@ -1380,7 +1380,7 @@
             } else if (ch == '%') {
                 replace = true;
                 list.add(new StringElement(buf.toString()));
-                buf = new StringBuffer();
+                buf = new StringBuilder();
             } else {
                 buf.append(ch);
             }

Modified: tomcat/trunk/java/org/apache/catalina/valves/ErrorReportValve.java
URL: http://svn.apache.org/viewvc/tomcat/trunk/java/org/apache/catalina/valves/ErrorReportValve.java?rev=832025&r1=832024&r2=832025&view=diff
==============================================================================
--- tomcat/trunk/java/org/apache/catalina/valves/ErrorReportValve.java (original)
+++ tomcat/trunk/java/org/apache/catalina/valves/ErrorReportValve.java Mon Nov  2 18:39:31
2009
@@ -180,7 +180,7 @@
         if (report == null)
             return;
 
-        StringBuffer sb = new StringBuffer();
+        StringBuilder sb = new StringBuilder();
 
         sb.append("<html><head><title>");
         sb.append(ServerInfo.getServerInfo()).append(" - ");
@@ -275,7 +275,7 @@
      * occurrence of javax.servlet.).
      */
     protected String getPartialServletStackTrace(Throwable t) {
-        StringBuffer trace = new StringBuffer();
+        StringBuilder trace = new StringBuilder();
         trace.append(t.toString()).append('\n');
         StackTraceElement[] elements = t.getStackTrace();
         int pos = elements.length;

Modified: tomcat/trunk/java/org/apache/catalina/valves/ExtendedAccessLogValve.java
URL: http://svn.apache.org/viewvc/tomcat/trunk/java/org/apache/catalina/valves/ExtendedAccessLogValve.java?rev=832025&r1=832024&r2=832025&view=diff
==============================================================================
--- tomcat/trunk/java/org/apache/catalina/valves/ExtendedAccessLogValve.java (original)
+++ tomcat/trunk/java/org/apache/catalina/valves/ExtendedAccessLogValve.java Mon Nov  2 18:39:31
2009
@@ -187,7 +187,7 @@
         }
 
         /* Wrap all quotes in double quotes. */
-        StringBuffer buffer = new StringBuffer(svalue.length() + 2);
+        StringBuilder buffer = new StringBuilder(svalue.length() + 2);
         buffer.append('\'');
         int i = 0;
         while (i < svalue.length()) {
@@ -233,7 +233,7 @@
             }
         };
                 
-        public void addElement(StringBuffer buf, Date date, Request request,
+        public void addElement(StringBuilder buf, Date date, Request request,
                 Response response, long time) {
             ElementTimestampStruct eds = currentDate.get();
             long millis = eds.currentTimestamp.getTime();
@@ -259,7 +259,7 @@
             }
         };
             
-        public void addElement(StringBuffer buf, Date date, Request request,
+        public void addElement(StringBuilder buf, Date date, Request request,
                 Response response, long time) {
             ElementTimestampStruct eds = currentTime.get();
             long millis = eds.currentTimestamp.getTime();
@@ -280,7 +280,7 @@
         public RequestHeaderElement(String header) {
             this.header = header;
         }
-        public void addElement(StringBuffer buf, Date date, Request request,
+        public void addElement(StringBuilder buf, Date date, Request request,
                 Response response, long time) {
             buf.append(wrap(request.getHeader(header)));
         }
@@ -293,7 +293,7 @@
             this.header = header;
         }
         
-        public void addElement(StringBuffer buf, Date date, Request request,
+        public void addElement(StringBuilder buf, Date date, Request request,
                 Response response, long time) {
             buf.append(wrap(response.getHeader(header)));
         }
@@ -305,7 +305,7 @@
         public ServletContextElement(String attribute) {
             this.attribute = attribute;
         }
-        public void addElement(StringBuffer buf, Date date, Request request,
+        public void addElement(StringBuilder buf, Date date, Request request,
                 Response response, long time) {
             buf.append(wrap(request.getContext().getServletContext()
                     .getAttribute(attribute)));
@@ -318,7 +318,7 @@
         public CookieElement(String name) {
             this.name = name;
         }
-        public void addElement(StringBuffer buf, Date date, Request request,
+        public void addElement(StringBuilder buf, Date date, Request request,
                 Response response, long time) {
             Cookie[] c = request.getCookies();
             for (int i = 0; c != null && i < c.length; i++) {
@@ -339,12 +339,12 @@
             this.header = header;
         }
         
-        public void addElement(StringBuffer buf, Date date, Request request,
+        public void addElement(StringBuilder buf, Date date, Request request,
                 Response response, long time) {
             if (null != response) {
                 Iterator<String> iter = response.getHeaders(header).iterator();
                 if (iter.hasNext()) {
-                    StringBuffer buffer = new StringBuffer();
+                    StringBuilder buffer = new StringBuilder();
                     boolean first = true;
                     while (iter.hasNext()) {
                         if (!first) {
@@ -367,7 +367,7 @@
             this.attribute = attribute;
         }
         
-        public void addElement(StringBuffer buf, Date date, Request request,
+        public void addElement(StringBuilder buf, Date date, Request request,
                 Response response, long time) {
             buf.append(wrap(request.getAttribute(attribute)));
         }        
@@ -379,7 +379,7 @@
         public SessionAttributeElement(String attribute) {
             this.attribute = attribute;
         }
-        public void addElement(StringBuffer buf, Date date, Request request,
+        public void addElement(StringBuilder buf, Date date, Request request,
                 Response response, long time) {
             HttpSession session = null;
             if (request != null) {
@@ -406,7 +406,7 @@
             return URLEncoder.encode(value);
         }   
         
-        public void addElement(StringBuffer buf, Date date, Request request,
+        public void addElement(StringBuilder buf, Date date, Request request,
                 Response response, long time) {
             buf.append(wrap(urlEncode(request.getParameter(parameter))));
         }
@@ -414,7 +414,7 @@
     
     protected class PatternTokenizer {
         private StringReader sr = null;
-        private StringBuffer buf = new StringBuffer();
+        private StringBuilder buf = new StringBuilder();
         private boolean ended = false;
         private boolean subToken;
         private boolean parameter;
@@ -444,22 +444,22 @@
                 switch (c) {
                 case ' ':
                     result = buf.toString();
-                    buf = new StringBuffer();
+                    buf = new StringBuilder();
                     buf.append((char) c);
                     return result;
                 case '-':
                     result = buf.toString();
-                    buf = new StringBuffer();
+                    buf = new StringBuilder();
                     subToken = true;
                     return result;
                 case '(':
                     result = buf.toString();
-                    buf = new StringBuffer();
+                    buf = new StringBuilder();
                     parameter = true;
                     return result;
                 case ')':
                     result = buf.toString();
-                    buf = new StringBuffer();
+                    buf = new StringBuilder();
                     break;
                 default:
                     buf.append((char) c);
@@ -484,7 +484,7 @@
             while (c != -1) {
                 if (c == ')') {
                     result = buf.toString();
-                    buf = new StringBuffer();
+                    buf = new StringBuilder();
                     return result;
                 }
                 buf.append((char) c);
@@ -496,10 +496,10 @@
         public String getWhiteSpaces() throws IOException {
             if(isEnded())
                 return "" ;
-            StringBuffer whiteSpaces = new StringBuffer();
+            StringBuilder whiteSpaces = new StringBuilder();
             if (buf.length() > 0) {
                 whiteSpaces.append(buf);
-                buf = new StringBuffer();
+                buf = new StringBuilder();
             }
             int c = sr.read();
             while (Character.isWhitespace((char) c)) {
@@ -519,7 +519,7 @@
         }
         
         public String getRemains() throws IOException {
-            StringBuffer remains = new StringBuffer();
+            StringBuilder remains = new StringBuilder();
             for(int c = sr.read(); c != -1; c = sr.read()) {
                 remains.append((char) c);
             }
@@ -604,7 +604,7 @@
                 return new LocalAddrElement();
             } else if ("dns".equals(nextToken)) {
                 return new AccessLogElement() {
-                    public void addElement(StringBuffer buf, Date date,
+                    public void addElement(StringBuilder buf, Date date,
                             Request request, Response response, long time) {
                         String value;
                         try {
@@ -642,7 +642,7 @@
                         return new RequestURIElement();
                     } else if ("query".equals(token)) {
                         return new AccessLogElement() {
-                            public void addElement(StringBuffer buf, Date date,
+                            public void addElement(StringBuilder buf, Date date,
                                     Request request, Response response,
                                     long time) {
                                 String query = request.getQueryString();
@@ -656,7 +656,7 @@
                     }
                 } else {
                     return new AccessLogElement() {
-                        public void addElement(StringBuffer buf, Date date,
+                        public void addElement(StringBuilder buf, Date date,
                                 Request request, Response response, long time) {
                             String query = request.getQueryString();
                             if (query == null) {
@@ -758,28 +758,28 @@
     protected AccessLogElement getServletRequestElement(String parameter) {
         if ("authType".equals(parameter)) {
             return new AccessLogElement() {
-                public void addElement(StringBuffer buf, Date date,
+                public void addElement(StringBuilder buf, Date date,
                         Request request, Response response, long time) {
                     buf.append(wrap(request.getAuthType()));
                 }
             };
         } else if ("remoteUser".equals(parameter)) {
             return new AccessLogElement() {
-                public void addElement(StringBuffer buf, Date date,
+                public void addElement(StringBuilder buf, Date date,
                         Request request, Response response, long time) {
                     buf.append(wrap(request.getRemoteUser()));
                 }
             };
         } else if ("requestedSessionId".equals(parameter)) {
             return new AccessLogElement() {
-                public void addElement(StringBuffer buf, Date date,
+                public void addElement(StringBuilder buf, Date date,
                         Request request, Response response, long time) {
                     buf.append(wrap(request.getRequestedSessionId()));
                 }
             };
         } else if ("requestedSessionIdFromCookie".equals(parameter)) {
             return new AccessLogElement() {
-                public void addElement(StringBuffer buf, Date date,
+                public void addElement(StringBuilder buf, Date date,
                         Request request, Response response, long time) {
                     buf.append(wrap(""
                             + request.isRequestedSessionIdFromCookie()));
@@ -787,49 +787,49 @@
             };
         } else if ("requestedSessionIdValid".equals(parameter)) {
             return new AccessLogElement() {
-                public void addElement(StringBuffer buf, Date date,
+                public void addElement(StringBuilder buf, Date date,
                         Request request, Response response, long time) {
                     buf.append(wrap("" + request.isRequestedSessionIdValid()));
                 }
             };
         } else if ("contentLength".equals(parameter)) {
             return new AccessLogElement() {
-                public void addElement(StringBuffer buf, Date date,
+                public void addElement(StringBuilder buf, Date date,
                         Request request, Response response, long time) {
                     buf.append(wrap("" + request.getContentLength()));
                 }
             };
         } else if ("characterEncoding".equals(parameter)) {
             return new AccessLogElement() {
-                public void addElement(StringBuffer buf, Date date,
+                public void addElement(StringBuilder buf, Date date,
                         Request request, Response response, long time) {
                     buf.append(wrap(request.getCharacterEncoding()));
                 }
             };
         } else if ("locale".equals(parameter)) {
             return new AccessLogElement() {
-                public void addElement(StringBuffer buf, Date date,
+                public void addElement(StringBuilder buf, Date date,
                         Request request, Response response, long time) {
                     buf.append(wrap(request.getLocale()));
                 }
             };
         } else if ("protocol".equals(parameter)) {
             return new AccessLogElement() {
-                public void addElement(StringBuffer buf, Date date,
+                public void addElement(StringBuilder buf, Date date,
                         Request request, Response response, long time) {
                     buf.append(wrap(request.getProtocol()));
                 }
             };
         } else if ("scheme".equals(parameter)) {
             return new AccessLogElement() {
-                public void addElement(StringBuffer buf, Date date,
+                public void addElement(StringBuilder buf, Date date,
                         Request request, Response response, long time) {
                     buf.append(request.getScheme());
                 }
             };
         } else if ("secure".equals(parameter)) {
             return new AccessLogElement() {
-                public void addElement(StringBuffer buf, Date date,
+                public void addElement(StringBuilder buf, Date date,
                         Request request, Response response, long time) {
                     buf.append(wrap("" + request.isSecure()));
                 }

Modified: tomcat/trunk/java/org/apache/catalina/valves/ValveBase.java
URL: http://svn.apache.org/viewvc/tomcat/trunk/java/org/apache/catalina/valves/ValveBase.java?rev=832025&r1=832024&r2=832025&view=diff
==============================================================================
--- tomcat/trunk/java/org/apache/catalina/valves/ValveBase.java (original)
+++ tomcat/trunk/java/org/apache/catalina/valves/ValveBase.java Mon Nov  2 18:39:31 2009
@@ -228,7 +228,7 @@
      * Return a String rendering of this object.
      */
     public String toString() {
-        StringBuffer sb = new StringBuffer(this.getClass().getName());
+        StringBuilder sb = new StringBuilder(this.getClass().getName());
         sb.append("[");
         if (container != null)
             sb.append(container.getName());



---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@tomcat.apache.org
For additional commands, e-mail: dev-help@tomcat.apache.org


Mime
View raw message