tomcat-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ma...@apache.org
Subject svn commit: r934234 - /tomcat/trunk/java/javax/servlet/http/HttpServlet.java
Date Wed, 14 Apr 2010 22:50:36 GMT
Author: markt
Date: Wed Apr 14 22:50:35 2010
New Revision: 934234

URL: http://svn.apache.org/viewvc?rev=934234&view=rev
Log:
https://issues.apache.org/bugzilla/show_bug.cgi?id=49118
Use StringBuilder rather than concatenation

Modified:
    tomcat/trunk/java/javax/servlet/http/HttpServlet.java

Modified: tomcat/trunk/java/javax/servlet/http/HttpServlet.java
URL: http://svn.apache.org/viewvc/tomcat/trunk/java/javax/servlet/http/HttpServlet.java?rev=934234&r1=934233&r2=934234&view=diff
==============================================================================
--- tomcat/trunk/java/javax/servlet/http/HttpServlet.java (original)
+++ tomcat/trunk/java/javax/servlet/http/HttpServlet.java Wed Apr 14 22:50:35 2010
@@ -559,25 +559,25 @@ public abstract class HttpServlet extend
         int responseLength;
         
         String CRLF = "\r\n";
-        String responseString = "TRACE "+ req.getRequestURI()+
-            " " + req.getProtocol();
+        StringBuilder buffer = new StringBuilder("TRACE ").append(req.getRequestURI())
+            .append(" ").append(req.getProtocol());
         
         Enumeration<String> reqHeaderEnum = req.getHeaderNames();
         
         while( reqHeaderEnum.hasMoreElements() ) {
             String headerName = reqHeaderEnum.nextElement();
-            responseString += CRLF + headerName + ": " +
-                req.getHeader(headerName); 
+            buffer.append(CRLF).append(headerName).append(": ")
+                .append(req.getHeader(headerName)); 
         }
         
-        responseString += CRLF;
+        buffer.append(CRLF);
         
-        responseLength = responseString.length();
+        responseLength = buffer.length();
         
         resp.setContentType("message/http");
         resp.setContentLength(responseLength);
         ServletOutputStream out = resp.getOutputStream();
-        out.print(responseString);        
+        out.print(buffer.toString());        
         out.close();
         return;
     }                



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


Mime
View raw message