This is an automated email from the ASF dual-hosted git repository.
schultz 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 4f109c8699 Don't create a StringBuilder object until we know we have
at least one Cookie value to log.
4f109c8699 is described below
commit 4f109c86994df4aa54ba31df424c4202a62ed367
Author: Christopher Schultz <[email protected]>
AuthorDate: Thu Apr 18 09:30:50 2024 -0400
Don't create a StringBuilder object until we know we have at least one
Cookie value to log.
---
java/org/apache/catalina/valves/AbstractAccessLogValve.java | 3 ++-
webapps/docs/changelog.xml | 4 ++++
2 files changed, 6 insertions(+), 1 deletion(-)
diff --git a/java/org/apache/catalina/valves/AbstractAccessLogValve.java
b/java/org/apache/catalina/valves/AbstractAccessLogValve.java
index 0287eab383..7a9c83d849 100644
--- a/java/org/apache/catalina/valves/AbstractAccessLogValve.java
+++ b/java/org/apache/catalina/valves/AbstractAccessLogValve.java
@@ -1483,7 +1483,7 @@ public abstract class AbstractAccessLogValve extends
ValveBase implements Access
@Override
public void addElement(CharArrayWriter buf, Date date, Request
request, Response response, long time) {
- StringBuilder value = new StringBuilder();
+ StringBuilder value = null;
boolean first = true;
Cookie[] cookies = request.getCookies();
if (cookies != null) {
@@ -1494,6 +1494,7 @@ public abstract class AbstractAccessLogValve extends
ValveBase implements Access
} else {
value.append(',');
}
+ value = new StringBuilder();
value.append(cookie.getValue());
}
}
diff --git a/webapps/docs/changelog.xml b/webapps/docs/changelog.xml
index de4e1b77a2..eeee325138 100644
--- a/webapps/docs/changelog.xml
+++ b/webapps/docs/changelog.xml
@@ -125,6 +125,10 @@
<code>trimCredentials</code> setting will be removed in Tomcat 11.
(markt)
</fix>
+ <add>
+ Small performance optimization when logging cookies with no values.
+ (schultz)
+ </add>
</changelog>
</subsection>
<subsection name="Coyote">
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]