This is an automated email from the ASF dual-hosted git repository.
markt pushed a commit to branch 8.5.x
in repository https://gitbox.apache.org/repos/asf/tomcat.git
The following commit(s) were added to refs/heads/8.5.x by this push:
new da1149391f Fix BZ 68026 - Convert selected MessageBytes values to
String type
da1149391f is described below
commit da1149391f83bcaced93cc0c6b0476a7efde31e1
Author: Mark Thomas <[email protected]>
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 dcf037a140..4955e49fa7 100644
--- a/java/org/apache/catalina/connector/Request.java
+++ b/java/org/apache/catalina/connector/Request.java
@@ -1216,7 +1216,7 @@ public class Request implements HttpServletRequest {
*/
@Override
public String getProtocol() {
- return coyoteRequest.protocol().toString();
+ return coyoteRequest.protocol().toStringType();
}
@@ -1448,7 +1448,7 @@ public class Request implements HttpServletRequest {
*/
@Override
public String getScheme() {
- return coyoteRequest.scheme().toString();
+ return coyoteRequest.scheme().toStringType();
}
@@ -2293,7 +2293,7 @@ public class Request implements HttpServletRequest {
*/
@Override
public String getMethod() {
- return coyoteRequest.method().toString();
+ return coyoteRequest.method().toStringType();
}
@@ -2302,7 +2302,7 @@ public class Request implements HttpServletRequest {
*/
@Override
public String getPathInfo() {
- return mappingData.pathInfo.toString();
+ return mappingData.pathInfo.toStringType();
}
@@ -2387,7 +2387,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 0d23e1d602..10e34d406a 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 ebc7c43140..a538221fe9 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: [email protected]
For additional commands, e-mail: [email protected]