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

markt pushed a commit to branch 9.0.x
in repository https://gitbox.apache.org/repos/asf/tomcat.git


The following commit(s) were added to refs/heads/9.0.x by this push:
     new b06cbf8955 Fix BZ 68026 - Convert selected MessageBytes values to 
String type
b06cbf8955 is described below

commit b06cbf8955e5d3f836ca52faba89d235648cc411
Author: Mark Thomas <ma...@apache.org>
AuthorDate: Mon Nov 6 17:10:56 2023 +0000

    Fix BZ 68026 - Convert selected MessageBytes values to String type
    
    https://bz.apache.org/bugzilla/show_bug.cgi?id=68026
---
 java/org/apache/catalina/connector/Request.java   | 10 +++++-----
 java/org/apache/tomcat/util/buf/MessageBytes.java | 24 +++++++++++++++++++++++
 webapps/docs/changelog.xml                        |  9 +++++++--
 3 files changed, 36 insertions(+), 7 deletions(-)

diff --git a/java/org/apache/catalina/connector/Request.java 
b/java/org/apache/catalina/connector/Request.java
index e5fb06f152..2f799d62c1 100644
--- a/java/org/apache/catalina/connector/Request.java
+++ b/java/org/apache/catalina/connector/Request.java
@@ -1188,7 +1188,7 @@ public class Request implements HttpServletRequest {
      */
     @Override
     public String getProtocol() {
-        return coyoteRequest.protocol().toString();
+        return coyoteRequest.protocol().toStringType();
     }
 
 
@@ -1438,7 +1438,7 @@ public class Request implements HttpServletRequest {
      */
     @Override
     public String getScheme() {
-        return coyoteRequest.scheme().toString();
+        return coyoteRequest.scheme().toStringType();
     }
 
 
@@ -2302,7 +2302,7 @@ public class Request implements HttpServletRequest {
      */
     @Override
     public String getMethod() {
-        return coyoteRequest.method().toString();
+        return coyoteRequest.method().toStringType();
     }
 
 
@@ -2311,7 +2311,7 @@ public class Request implements HttpServletRequest {
      */
     @Override
     public String getPathInfo() {
-        return mappingData.pathInfo.toString();
+        return mappingData.pathInfo.toStringType();
     }
 
 
@@ -2396,7 +2396,7 @@ public class Request implements HttpServletRequest {
      */
     @Override
     public String getServletPath() {
-        return mappingData.wrapperPath.toString();
+        return mappingData.wrapperPath.toStringType();
     }
 
 
diff --git a/java/org/apache/tomcat/util/buf/MessageBytes.java 
b/java/org/apache/tomcat/util/buf/MessageBytes.java
index f678b77f92..0eee6e75d4 100644
--- a/java/org/apache/tomcat/util/buf/MessageBytes.java
+++ b/java/org/apache/tomcat/util/buf/MessageBytes.java
@@ -180,6 +180,30 @@ public final class MessageBytes implements Cloneable, 
Serializable {
         return strValue;
     }
 
+
+    /**
+     * Convert to String (if not already of the String type) and then return 
the String value.
+     *
+     * @return The current value as a String
+     */
+    public String toStringType() {
+        switch (type) {
+            case T_NULL:
+            case T_STR:
+                // No conversion required
+                break;
+            case T_BYTES:
+                setString(byteC.toString());
+                break;
+            case T_CHARS:
+                setString(charC.toString());
+                break;
+        }
+
+        return strValue;
+    }
+
+
     // ----------------------------------------
     /**
      * Return the type of the original content. Can be T_STR, T_BYTES, T_CHARS 
or T_NULL
diff --git a/webapps/docs/changelog.xml b/webapps/docs/changelog.xml
index 43ca6513ef..ef17aee76b 100644
--- a/webapps/docs/changelog.xml
+++ b/webapps/docs/changelog.xml
@@ -179,8 +179,13 @@
         does not. (markt)
       </fix>
       <fix>
-        <bug>67938</bug>: Correct handling of large TLS client hello messages 
that
-        were causing the TLS handshake to fail. (markt)
+        <bug>67938</bug>: Correct handling of large TLS client hello messages
+        that were causing the TLS handshake to fail. (markt)
+      </fix>
+      <fix>
+        <bug>68026</bug>: Convert selected <code>MessageByte</code> values to
+        String when first accessed to speed up subsequent accesses and reduce
+        garbage collection. (markt)
       </fix>
     </changelog>
   </subsection>


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

Reply via email to