Author: markt
Date: Thu Oct 14 17:37:20 2010
New Revision: 1022623
URL: http://svn.apache.org/viewvc?rev=1022623&view=rev
Log:
Enhance fix for https://issues.apache.org/bugzilla/show_bug.cgi?id=50078
Make cache sizes configurable
Modified:
tomcat/trunk/java/javax/el/BeanELResolver.java
tomcat/trunk/java/org/apache/el/lang/ExpressionBuilder.java
tomcat/trunk/webapps/docs/config/systemprops.xml
Modified: tomcat/trunk/java/javax/el/BeanELResolver.java
URL:
http://svn.apache.org/viewvc/tomcat/trunk/java/javax/el/BeanELResolver.java?rev=1022623&r1=1022622&r2=1022623&view=diff
==============================================================================
--- tomcat/trunk/java/javax/el/BeanELResolver.java (original)
+++ tomcat/trunk/java/javax/el/BeanELResolver.java Thu Oct 14 17:37:20 2010
@@ -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.ConcurrentHa
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<Integer>() {
+
+ @Override
+ public Integer run() {
+ return Integer.valueOf(
+ System.getProperty(CACHE_SIZE_PROP, "1000"));
+ }
+ }).intValue();
+ }
+ }
+
private final boolean readOnly;
private final ConcurrentCache<String, BeanProperties> cache =
- new ConcurrentCache<String, BeanProperties>(1000);
+ new ConcurrentCache<String, BeanProperties>(CACHE_SIZE);
public BeanELResolver() {
this.readOnly = false;
Modified: tomcat/trunk/java/org/apache/el/lang/ExpressionBuilder.java
URL:
http://svn.apache.org/viewvc/tomcat/trunk/java/org/apache/el/lang/ExpressionBuilder.java?rev=1022623&r1=1022622&r2=1022623&view=diff
==============================================================================
--- tomcat/trunk/java/org/apache/el/lang/ExpressionBuilder.java (original)
+++ tomcat/trunk/java/org/apache/el/lang/ExpressionBuilder.java Thu Oct 14
17:37:20 2010
@@ -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<Integer>() {
+
+ @Override
+ public Integer run() {
+ return Integer.valueOf(
+ System.getProperty(CACHE_SIZE_PROP, "5000"));
+ }
+ }).intValue();
+ }
+ }
+
private static final ConcurrentCache<String, Node> cache =
- new ConcurrentCache<String, Node>(5000);
+ new ConcurrentCache<String, Node>(CACHE_SIZE);
private FunctionMapper fnMapper;
Modified: tomcat/trunk/webapps/docs/config/systemprops.xml
URL:
http://svn.apache.org/viewvc/tomcat/trunk/webapps/docs/config/systemprops.xml?rev=1022623&r1=1022622&r2=1022623&view=diff
==============================================================================
--- tomcat/trunk/webapps/docs/config/systemprops.xml (original)
+++ tomcat/trunk/webapps/docs/config/systemprops.xml Thu Oct 14 17:37:20 2010
@@ -80,6 +80,18 @@
<code>false</code> will be used.</p>
</property>
+ <property name="org.apache.el.BeanELResolver.CACHE_SIZE">
+ <p>The number of javax.el.BeanELResolver.BeanProperties objects that will
+ be cached by the EL Parser. If not specified, the default of
+ <code>1000</code> will be used.</p>
+ </property>
+
+ <property name="org.apache.el.ExpressionBuilder.CACHE_SIZE">
+ <p>The number of parsed EL expressions that will be cached by the EL
+ Parser. If not specified, the default of <code>5000</code> will be used.
+ </p>
+ </property>
+
</properties>
</section>
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]