tomcat-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Konstantin Kolinko <knst.koli...@gmail.com>
Subject Re: svn commit: r1022606 - in /tomcat/trunk/java: javax/el/BeanELResolver.java org/apache/el/lang/ExpressionBuilder.java org/apache/el/util/ConcurrentCache.java
Date Fri, 15 Oct 2010 20:28:23 GMT
2010/10/14  <markt@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-unsubscribe@tomcat.apache.org
For additional commands, e-mail: dev-help@tomcat.apache.org


Mime
View raw message