The purge() method causes ConcurrentModificationException as it uses 
map.remove() in the middle of iteration. I've changed it to use 
Iterator.remove()

     public void purge() {
         Map map = getMap();
         Set keys = map.keySet();
         if ( keys == null ) {
             return;
         }
         for ( Iterator i = keys.iterator(); i.hasNext(); ) {
             Object key = (Object) i.next();
             Reference ref = (Reference) map.get( key );
             if ( ref.get() == null ) {
                 i.remove();       // <-- Modified line
             }
         }
     }

Besides, I have a modified SoftRefHashMap version which does more efficient 
purging by using the java.lang.ref.ReferenceQueue, similar to what 
java.util.WeakHashMap does. Should I post the modification to the mailing list?

-- 
John Yu                       Scioworks Technologies
e: [EMAIL PROTECTED]         w: +(65) 873 5989
w: http://www.scioworks.com   m: +(65) 9782 9610

Scioworks Camino - "Rapid WebApp Assembly for Struts"


--
To unsubscribe, e-mail:   <mailto:[EMAIL PROTECTED]>
For additional commands, e-mail: <mailto:[EMAIL PROTECTED]>

Reply via email to