View | Details | Raw Unified | Return to bug 49510
Collapse All | Expand All

(-)src/main/java/org/apache/taglibs/standard/lang/jstl/ELEvaluator.java (-7 / +13 lines)
Lines 22-37 Link Here
22
import java.text.MessageFormat;
22
import java.text.MessageFormat;
23
import java.util.Collections;
23
import java.util.Collections;
24
import java.util.HashMap;
24
import java.util.HashMap;
25
import java.util.LinkedHashMap;
25
import java.util.Map;
26
import java.util.Map;
26
27
27
import org.apache.taglibs.standard.lang.jstl.parser.ELParser;
28
import org.apache.taglibs.standard.lang.jstl.parser.ELParser;
28
import org.apache.taglibs.standard.lang.jstl.parser.ParseException;
29
import org.apache.taglibs.standard.lang.jstl.parser.ParseException;
29
import org.apache.taglibs.standard.lang.jstl.parser.Token;
30
import org.apache.taglibs.standard.lang.jstl.parser.Token;
30
import org.apache.taglibs.standard.lang.jstl.parser.TokenMgrError;
31
import org.apache.taglibs.standard.lang.jstl.parser.TokenMgrError;
31
import org.apache.taglibs.standard.extra.commons.collections.map.LRUMap;
32
32
33
import javax.servlet.jsp.PageContext;
33
import javax.servlet.jsp.PageContext;
34
import javax.servlet.jsp.jstl.core.Config;
35
34
36
/**
35
/**
37
 *
36
 *
Lines 378-395 Link Here
378
        return;
377
        return;
379
      }
378
      }
380
379
380
      final int maxSize;
381
      if( (pageContext != null) && (pageContext.getServletContext() != null) ) {
381
      if( (pageContext != null) && (pageContext.getServletContext() != null) ) {
382
383
          String value = pageContext.getServletContext().getInitParameter(EXPR_CACHE_PARAM);
382
          String value = pageContext.getServletContext().getInitParameter(EXPR_CACHE_PARAM);
384
          if (value != null) {
383
          if (value != null) {
385
            sCachedExpressionStrings = Collections.synchronizedMap(new LRUMap(Integer.parseInt(value)));
384
              maxSize = Integer.valueOf(value);
386
            return;
385
          } else {
386
              maxSize = MAX_SIZE;
387
          }
387
          }
388
388
      } else {
389
          maxSize = MAX_SIZE;
389
      }
390
      }
390
391
391
      // fall through if it couldn't find the parameter
392
      // fall through if it couldn't find the parameter
392
      sCachedExpressionStrings = Collections.synchronizedMap(new LRUMap(MAX_SIZE));
393
      sCachedExpressionStrings = Collections.synchronizedMap(new LinkedHashMap() {
394
          @Override
395
          protected boolean removeEldestEntry(Map.Entry eldest) {
396
              return size() > maxSize;
397
          }
398
      });
393
  }
399
  }
394
400
395
  //-------------------------------------
401
  //-------------------------------------
(-)src/main/java/org/apache/taglibs/standard/tag/common/fmt/FormatDateSupport.java (-15 / +11 lines)
Lines 20-30 Link Here
20
import java.io.IOException;
20
import java.io.IOException;
21
import java.text.DateFormat;
21
import java.text.DateFormat;
22
import java.text.SimpleDateFormat;
22
import java.text.SimpleDateFormat;
23
import java.util.Date;
23
import java.util.*;
24
import java.util.Locale;
25
import java.util.TimeZone;
26
import java.util.Collections;
27
import java.util.Map;
28
24
29
import javax.servlet.jsp.JspException;
25
import javax.servlet.jsp.JspException;
30
import javax.servlet.jsp.JspTagException;
26
import javax.servlet.jsp.JspTagException;
Lines 34-41 Link Here
34
import org.apache.taglibs.standard.resources.Resources;
30
import org.apache.taglibs.standard.resources.Resources;
35
import org.apache.taglibs.standard.tag.common.core.Util;
31
import org.apache.taglibs.standard.tag.common.core.Util;
36
32
37
import org.apache.taglibs.standard.extra.commons.collections.map.LRUMap;
38
39
/**
33
/**
40
 * Support for tag handlers for <formatDate>, the date and time
34
 * Support for tag handlers for <formatDate>, the date and time
41
 * formatting tag in JSTL 1.0.
35
 * formatting tag in JSTL 1.0.
Lines 194-207 Link Here
194
	DateFormat formatter = null;
188
	DateFormat formatter = null;
195
189
196
	// lazy initialization of cache
190
	// lazy initialization of cache
197
	if (dateFormatCache == null) {
191
    if (dateFormatCache == null) {
198
		String value = pageContext.getServletContext().getInitParameter(DATE_CACHE_PARAM);
192
        String value = pageContext.getServletContext().getInitParameter(DATE_CACHE_PARAM);
199
		if (value != null) {
193
        final int maxSize = (value != null) ? Integer.parseInt(value) : MAX_SIZE;
200
			dateFormatCache = Collections.synchronizedMap(new LRUMap(Integer.parseInt(value)));
194
        dateFormatCache = Collections.synchronizedMap(new LinkedHashMap() {
201
		} else {
195
          @Override
202
			dateFormatCache = Collections.synchronizedMap(new LRUMap(MAX_SIZE));
196
            protected boolean removeEldestEntry(Map.Entry eldest) {
203
		}
197
            return size() > maxSize;
204
	}
198
            }
199
       });
200
    }
205
201
206
	// Apply pattern, if present
202
	// Apply pattern, if present
207
	if (pattern != null) {
203
	if (pattern != null) {

Return to bug 49510