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, 22 Oct 2010 23:52:30 GMT
2010/10/16 Konstantin Kolinko <knst.kolinko@gmail.com>:
> 2010/10/16 Tim Whittington <timw@apache.org>:
>>>> 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.
>>

For a note: I was wrong here.  A ReadWriteLock cannot be used, because
a get() operation on a Map is generally not guaranteed to do not
change the state of the map.

The WeakHashMap modifies itself in a get(): it deletes stale values.
The other JRE implementations may be even different.

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