This is an automated email from the ASF dual-hosted git repository. markt pushed a commit to branch main in repository https://gitbox.apache.org/repos/asf/tomcat.git
The following commit(s) were added to refs/heads/main by this push: new bec0dc510e Fix BZ 68026 - Convert selected MessageBytes values to String type bec0dc510e is described below commit bec0dc510eee2dd1587cf3c51a56ed69f5f63da0 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 aa67ec5df5..bda5dc2da4 100644 --- a/java/org/apache/catalina/connector/Request.java +++ b/java/org/apache/catalina/connector/Request.java @@ -1112,7 +1112,7 @@ public class Request implements HttpServletRequest { */ @Override public String getProtocol() { - return coyoteRequest.protocol().toString(); + return coyoteRequest.protocol().toStringType(); } @@ -1334,7 +1334,7 @@ public class Request implements HttpServletRequest { */ @Override public String getScheme() { - return coyoteRequest.scheme().toString(); + return coyoteRequest.scheme().toStringType(); } @@ -2167,7 +2167,7 @@ public class Request implements HttpServletRequest { */ @Override public String getMethod() { - return coyoteRequest.method().toString(); + return coyoteRequest.method().toStringType(); } @@ -2176,7 +2176,7 @@ public class Request implements HttpServletRequest { */ @Override public String getPathInfo() { - return mappingData.pathInfo.toString(); + return mappingData.pathInfo.toStringType(); } @@ -2261,7 +2261,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 10a6016ba4..0de3053c24 100644 --- a/java/org/apache/tomcat/util/buf/MessageBytes.java +++ b/java/org/apache/tomcat/util/buf/MessageBytes.java @@ -179,6 +179,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 9085d69063..f64374e2f2 100644 --- a/webapps/docs/changelog.xml +++ b/webapps/docs/changelog.xml @@ -185,8 +185,13 @@ refuse new connections or the JVM to crash. (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