This is an automated email from the ASF dual-hosted git repository. markt pushed a commit to branch 10.1.x in repository https://gitbox.apache.org/repos/asf/tomcat.git
The following commit(s) were added to refs/heads/10.1.x by this push: new 453e09ee0d Fix BZ 68026 - Convert selected MessageBytes values to String type 453e09ee0d is described below commit 453e09ee0d3fb7019efd249d7998c26a11683b43 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 88bb9bc822..935a38d932 100644 --- a/java/org/apache/catalina/connector/Request.java +++ b/java/org/apache/catalina/connector/Request.java @@ -1159,7 +1159,7 @@ public class Request implements HttpServletRequest { */ @Override public String getProtocol() { - return coyoteRequest.protocol().toString(); + return coyoteRequest.protocol().toStringType(); } @@ -1381,7 +1381,7 @@ public class Request implements HttpServletRequest { */ @Override public String getScheme() { - return coyoteRequest.scheme().toString(); + return coyoteRequest.scheme().toStringType(); } @@ -2264,7 +2264,7 @@ public class Request implements HttpServletRequest { */ @Override public String getMethod() { - return coyoteRequest.method().toString(); + return coyoteRequest.method().toStringType(); } @@ -2273,7 +2273,7 @@ public class Request implements HttpServletRequest { */ @Override public String getPathInfo() { - return mappingData.pathInfo.toString(); + return mappingData.pathInfo.toStringType(); } @@ -2358,7 +2358,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 d71eb9e23f..ba915c7bb6 100644 --- a/webapps/docs/changelog.xml +++ b/webapps/docs/changelog.xml @@ -174,8 +174,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