This is an automated email from the ASF dual-hosted git repository.

markt 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 e0d344f  Allow for path length in cached resource size
e0d344f is described below

commit e0d344fa717b297d6569a2ce7d60c2e18283d8a0
Author: Mark Thomas <ma...@apache.org>
AuthorDate: Mon Oct 5 19:05:57 2020 +0100

    Allow for path length in cached resource size
    
    Based on PR #368
---
 java/org/apache/catalina/webresources/CachedResource.java | 4 ++++
 webapps/docs/changelog.xml                                | 5 +++++
 2 files changed, 9 insertions(+)

diff --git a/java/org/apache/catalina/webresources/CachedResource.java 
b/java/org/apache/catalina/webresources/CachedResource.java
index db4c6d5..ea15590 100644
--- a/java/org/apache/catalina/webresources/CachedResource.java
+++ b/java/org/apache/catalina/webresources/CachedResource.java
@@ -414,6 +414,10 @@ public class CachedResource implements WebResource {
     // case but it makes tracking the current cache size easier.
     long getSize() {
         long result = CACHE_ENTRY_SIZE;
+        // Longer paths use a noticeable amount of memory so account for this 
in
+        // the cache size. The fixed component of a String instance's memory
+        // usage is accounted for in the 500 bytes above.
+        result += getWebappPath().length() * 2;
         if (getContentLength() <= objectMaxSizeBytes) {
             result += getContentLength();
         }
diff --git a/webapps/docs/changelog.xml b/webapps/docs/changelog.xml
index 55b3b94..b715981 100644
--- a/webapps/docs/changelog.xml
+++ b/webapps/docs/changelog.xml
@@ -108,6 +108,11 @@
       <update>
         Add connection pooling to JNDI realm. (remm)
       </update>
+      <fix>
+        When estimating the size of a resource in the static resource cache,
+        include a specific allowance for the path to the resource. Based on a
+        pull request by blueSky1825821. (markt)
+      </fix>
     </changelog>
   </subsection>
   <subsection name="Coyote">


---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscr...@tomcat.apache.org
For additional commands, e-mail: dev-h...@tomcat.apache.org

Reply via email to