This is an automated email from the ASF dual-hosted git repository.
markt-asf 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 45e7bd9669 Fix BZ 70296 - Use longs for StringCache stats
45e7bd9669 is described below
commit 45e7bd9669d72b4709257f9e227b76c5c261f8b7
Author: Mark Thomas <[email protected]>
AuthorDate: Wed Nov 11 20:13:31 2026 +0000
Fix BZ 70296 - Use longs for StringCache stats
---
java/org/apache/tomcat/util/buf/StringCache.java | 46 +++++++++++++++++++++---
webapps/docs/changelog.xml | 5 +++
2 files changed, 46 insertions(+), 5 deletions(-)
diff --git a/java/org/apache/tomcat/util/buf/StringCache.java
b/java/org/apache/tomcat/util/buf/StringCache.java
index 15103822fc..bbf45010ac 100644
--- a/java/org/apache/tomcat/util/buf/StringCache.java
+++ b/java/org/apache/tomcat/util/buf/StringCache.java
@@ -118,13 +118,13 @@ public class StringCache {
/**
* Access count.
*/
- protected static int accessCount = 0;
+ protected static long accessCount = 0;
/**
* Hit count.
*/
- protected static int hitCount = 0;
+ protected static long hitCount = 0;
// ------------------------------------------------------------ Properties
@@ -211,28 +211,64 @@ public class StringCache {
/**
- * Returns the total number of cache lookups performed.
+ * Returns the total number of cache lookups performed. If the total is
more than {@link Integer#MAX_VALUE},
+ * {@link Integer#MAX_VALUE} is returned.
*
* @return the access count
+ *
+ * @deprecated Use {@link #getAccessCountLong()}. This method will be
removed in Tomcat 12.0.x onwards.
*/
+ @Deprecated
public int getAccessCount() {
+ long accessCount = StringCache.accessCount;
+ if (accessCount > Integer.MAX_VALUE) {
+ return Integer.MAX_VALUE;
+ } else {
+ return (int) accessCount;
+ }
+ }
+
+
+ /**
+ * Returns the total number of cache lookups performed.
+ *
+ * @return the access count
+ */
+ public long getAccessCountLong() {
return accessCount;
}
+ /**
+ * Returns the number of cache hits. If the total is more than {@link
Integer#MAX_VALUE}, {@link Integer#MAX_VALUE}
+ * is returned.
+ *
+ * @return the hit count
+ *
+ * @deprecated Use {@link #getHitCountLong()}. This method will be removed
in Tomcat 12.0.x onwards.
+ */
+ @Deprecated
+ public int getHitCount() {
+ long hitCount = StringCache.hitCount;
+ if (hitCount > Integer.MAX_VALUE) {
+ return Integer.MAX_VALUE;
+ } else {
+ return (int) hitCount;
+ }
+ }
+
/**
* Returns the number of cache hits.
*
* @return the hit count
*/
- public int getHitCount() {
+ public long getHitCountLong() {
return hitCount;
}
// -------------------------------------------------- Public Static Methods
-
/**
* Resets all cache statistics and clears the cache.
*/
diff --git a/webapps/docs/changelog.xml b/webapps/docs/changelog.xml
index 7344afc470..42cf94e02f 100644
--- a/webapps/docs/changelog.xml
+++ b/webapps/docs/changelog.xml
@@ -118,6 +118,11 @@
<bug>70288</bug>: Fix bug that could cause request body truncation with
HTTP/2. Based on a patch by Alberto Limón. (markt)
</fix>
+ <fix>
+ <bug>70296</bug>: Update the <code>StringCache</code> to report access
+ counts and hit counts as <code>long</code> rather than
<code>int</code>.
+ (markt)
+ </fix>
</changelog>
</subsection>
<subsection name="Jasper">
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]