Author: markt
Date: Thu Oct 14 16:36:20 2010
New Revision: 1022606
URL: http://svn.apache.org/viewvc?rev=1022606&view=rev
Log:
Fix https://issues.apache.org/bugzilla/show_bug.cgi?id=50078
Thread safety in EL caches. Patch provided by Takayoshi Kimura
Modified:
tomcat/trunk/java/javax/el/BeanELResolver.java
tomcat/trunk/java/org/apache/el/lang/ExpressionBuilder.java
tomcat/trunk/java/org/apache/el/util/ConcurrentCache.java
Modified: tomcat/trunk/java/javax/el/BeanELResolver.java
URL:
http://svn.apache.org/viewvc/tomcat/trunk/java/javax/el/BeanELResolver.java?rev=1022606&r1=1022605&r2=1022606&view=diff
==============================================================================
--- tomcat/trunk/java/javax/el/BeanELResolver.java (original)
+++ tomcat/trunk/java/javax/el/BeanELResolver.java Thu Oct 14 16:36:20 2010
@@ -334,7 +334,9 @@ public class BeanELResolver extends ELRe
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 ELRe
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);
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=1022606&r1=1022605&r2=1022606&view=diff
==============================================================================
--- tomcat/trunk/java/org/apache/el/lang/ExpressionBuilder.java (original)
+++ tomcat/trunk/java/org/apache/el/lang/ExpressionBuilder.java Thu Oct 14
16:36:20 2010
@@ -49,7 +49,8 @@ import org.apache.el.util.MessageFactory
*/
public final class ExpressionBuilder implements NodeVisitor {
- private static final ConcurrentCache<String, Node> cache = new
ConcurrentCache<String, Node>(5000);
+ private static final ConcurrentCache<String, Node> cache =
+ new ConcurrentCache<String, Node>(5000);
private FunctionMapper fnMapper;
Modified: tomcat/trunk/java/org/apache/el/util/ConcurrentCache.java
URL:
http://svn.apache.org/viewvc/tomcat/trunk/java/org/apache/el/util/ConcurrentCache.java?rev=1022606&r1=1022605&r2=1022606&view=diff
==============================================================================
--- tomcat/trunk/java/org/apache/el/util/ConcurrentCache.java (original)
+++ tomcat/trunk/java/org/apache/el/util/ConcurrentCache.java Thu Oct 14
16:36:20 2010
@@ -37,7 +37,9 @@ public final class ConcurrentCache<K,V>
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<K,V>
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);
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]