2010/10/14  <ma...@apache.org>:
> 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
>

(...)
>         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);
>

I think that a ReadWriteLock will be more suitable here,  because
there will be a thousand of reads for a single write.

>                 this.eden.clear();
Shouldn't the above line be inside the lock as well?

Best regards,
Konstantin Kolinko

---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscr...@tomcat.apache.org
For additional commands, e-mail: dev-h...@tomcat.apache.org

Reply via email to