From: markt Date: Thu, 14 Oct 2010 16:36:20 +0000 (+0000) Subject: Fix https://issues.apache.org/bugzilla/show_bug.cgi?id=50078 X-Git-Url: https://git.internetallee.de/?a=commitdiff_plain;h=b7965160c2d8e81f86ee92ef31c344983727823d;p=tomcat7.0 Fix https://issues.apache.org/bugzilla/show_bug.cgi?id=50078 Thread safety in EL caches. Patch provided by Takayoshi Kimura git-svn-id: https://svn.apache.org/repos/asf/tomcat/trunk@1022606 13f79535-47bb-0310-9956-ffa450edef68 --- diff --git a/java/javax/el/BeanELResolver.java b/java/javax/el/BeanELResolver.java index dacb20535..f93f4a6d2 100644 --- a/java/javax/el/BeanELResolver.java +++ b/java/javax/el/BeanELResolver.java @@ -334,7 +334,9 @@ public class BeanELResolver extends ELResolver { public V get(K key) { V value = this.eden.get(key); if (value == null) { - value = this.longterm.get(key); + synchronized (longterm) { + value = this.longterm.get(key); + } if (value != null) { this.eden.put(key, value); } @@ -344,7 +346,9 @@ public class BeanELResolver extends ELResolver { public void put(K key, V value) { if (this.eden.size() >= this.size) { - this.longterm.putAll(this.eden); + synchronized (longterm) { + this.longterm.putAll(this.eden); + } this.eden.clear(); } this.eden.put(key, value); diff --git a/java/org/apache/el/lang/ExpressionBuilder.java b/java/org/apache/el/lang/ExpressionBuilder.java index c72cf0c54..079c733d5 100644 --- a/java/org/apache/el/lang/ExpressionBuilder.java +++ b/java/org/apache/el/lang/ExpressionBuilder.java @@ -49,7 +49,8 @@ import org.apache.el.util.MessageFactory; */ public final class ExpressionBuilder implements NodeVisitor { - private static final ConcurrentCache cache = new ConcurrentCache(5000); + private static final ConcurrentCache cache = + new ConcurrentCache(5000); private FunctionMapper fnMapper; diff --git a/java/org/apache/el/util/ConcurrentCache.java b/java/org/apache/el/util/ConcurrentCache.java index 5515b0e70..26029bbc1 100644 --- a/java/org/apache/el/util/ConcurrentCache.java +++ b/java/org/apache/el/util/ConcurrentCache.java @@ -37,7 +37,9 @@ public final class ConcurrentCache { public V get(K k) { V v = this.eden.get(k); if (v == null) { - v = this.longterm.get(k); + synchronized (longterm) { + v = this.longterm.get(k); + } if (v != null) { this.eden.put(k, v); } @@ -47,7 +49,9 @@ public final class ConcurrentCache { public void put(K k, V v) { if (this.eden.size() >= size) { - this.longterm.putAll(this.eden); + synchronized (longterm) { + this.longterm.putAll(this.eden); + } this.eden.clear(); } this.eden.put(k, v);