- 41057: Caching large strings uses too much memory and is a bit pointless, so add...
authorremm <remm@13f79535-47bb-0310-9956-ffa450edef68>
Wed, 29 Nov 2006 00:30:07 +0000 (00:30 +0000)
committerremm <remm@13f79535-47bb-0310-9956-ffa450edef68>
Wed, 29 Nov 2006 00:30:07 +0000 (00:30 +0000)
git-svn-id: https://svn.apache.org/repos/asf/tomcat/tc6.0.x/trunk@480302 13f79535-47bb-0310-9956-ffa450edef68

java/org/apache/tomcat/util/buf/StringCache.java

index 50f5b2f..423fed9 100644 (file)
@@ -56,7 +56,11 @@ public class StringCache {
         Integer.parseInt(System.getProperty("tomcat.util.buf.StringCache.cacheSize", "200"));
     
 
-    /**
+    protected static int maxStringSize = 
+        Integer.parseInt(System.getProperty("tomcat.util.buf.StringCache.maxStringSize", "128"));
+    
+
+   /**
      * Statistics hash map for byte chunk.
      */
     protected static HashMap bcStats = new HashMap(cacheSize);
@@ -210,7 +214,7 @@ public class StringCache {
         // still training
         if (bcCache == null) {
             String value = bc.toStringInternal();
-            if (byteEnabled) {
+            if (byteEnabled && (value.length() < maxStringSize)) {
                 // If training, everything is synced
                 synchronized (bcStats) {
                     // If the cache has been generated on a previous invocation
@@ -324,7 +328,7 @@ public class StringCache {
         // still training
         if (ccCache == null) {
             String value = cc.toStringInternal();
-            if (charEnabled) {
+            if (charEnabled && (value.length() < maxStringSize)) {
                 // If training, everything is synced
                 synchronized (ccStats) {
                     // If the cache has been generated on a previous invocation