From: markt Date: Thu, 14 Oct 2010 17:37:20 +0000 (+0000) Subject: Enhance fix for https://issues.apache.org/bugzilla/show_bug.cgi?id=50078 X-Git-Url: https://git.internetallee.de/?a=commitdiff_plain;h=07492de966ecd17c20637a0bdb7f1b24b9b8b0f7;p=tomcat7.0 Enhance fix for https://issues.apache.org/bugzilla/show_bug.cgi?id=50078 Make cache sizes configurable git-svn-id: https://svn.apache.org/repos/asf/tomcat/trunk@1022623 13f79535-47bb-0310-9956-ffa450edef68 --- diff --git a/java/javax/el/BeanELResolver.java b/java/javax/el/BeanELResolver.java index f93f4a6d2..3476dc1ee 100644 --- a/java/javax/el/BeanELResolver.java +++ b/java/javax/el/BeanELResolver.java @@ -26,6 +26,8 @@ import java.lang.reflect.Array; import java.lang.reflect.InvocationTargetException; import java.lang.reflect.Method; import java.lang.reflect.Modifier; +import java.security.AccessController; +import java.security.PrivilegedAction; import java.util.Arrays; import java.util.HashMap; import java.util.Iterator; @@ -35,10 +37,31 @@ import java.util.concurrent.ConcurrentHashMap; public class BeanELResolver extends ELResolver { + private static final int CACHE_SIZE; + private static final String CACHE_SIZE_PROP = + "org.apache.el.BeanELResolver.CACHE_SIZE"; + + static { + if (System.getSecurityManager() == null) { + CACHE_SIZE = Integer.parseInt( + System.getProperty(CACHE_SIZE_PROP, "1000")); + } else { + CACHE_SIZE = AccessController.doPrivileged( + new PrivilegedAction() { + + @Override + public Integer run() { + return Integer.valueOf( + System.getProperty(CACHE_SIZE_PROP, "1000")); + } + }).intValue(); + } + } + private final boolean readOnly; private final ConcurrentCache cache = - new ConcurrentCache(1000); + new ConcurrentCache(CACHE_SIZE); public BeanELResolver() { this.readOnly = false; diff --git a/java/org/apache/el/lang/ExpressionBuilder.java b/java/org/apache/el/lang/ExpressionBuilder.java index 079c733d5..1c0c3e5a3 100644 --- a/java/org/apache/el/lang/ExpressionBuilder.java +++ b/java/org/apache/el/lang/ExpressionBuilder.java @@ -19,6 +19,8 @@ package org.apache.el.lang; import java.io.StringReader; import java.lang.reflect.Method; +import java.security.AccessController; +import java.security.PrivilegedAction; import javax.el.ELContext; import javax.el.ELException; @@ -49,8 +51,29 @@ import org.apache.el.util.MessageFactory; */ public final class ExpressionBuilder implements NodeVisitor { + private static final int CACHE_SIZE; + private static final String CACHE_SIZE_PROP = + "org.apache.el.ExpressionBuilder.CACHE_SIZE"; + + static { + if (System.getSecurityManager() == null) { + CACHE_SIZE = Integer.parseInt( + System.getProperty(CACHE_SIZE_PROP, "5000")); + } else { + CACHE_SIZE = AccessController.doPrivileged( + new PrivilegedAction() { + + @Override + public Integer run() { + return Integer.valueOf( + System.getProperty(CACHE_SIZE_PROP, "5000")); + } + }).intValue(); + } + } + private static final ConcurrentCache cache = - new ConcurrentCache(5000); + new ConcurrentCache(CACHE_SIZE); private FunctionMapper fnMapper; diff --git a/webapps/docs/config/systemprops.xml b/webapps/docs/config/systemprops.xml index 591bc7c2f..5ce3c7ad2 100644 --- a/webapps/docs/config/systemprops.xml +++ b/webapps/docs/config/systemprops.xml @@ -80,6 +80,18 @@ false will be used.

+ +

The number of javax.el.BeanELResolver.BeanProperties objects that will + be cached by the EL Parser. If not specified, the default of + 1000 will be used.

+
+ + +

The number of parsed EL expressions that will be cached by the EL + Parser. If not specified, the default of 5000 will be used. +

+
+