commons-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From James Carman <ja...@carmanconsulting.com>
Subject Re: [collections] LRUMap Problem ConcurrentModificationException
Date Wed, 17 Jun 2009 14:23:58 GMT
Or, ehcache or oscache or something like that?

On Wed, Jun 17, 2009 at 10:17 AM, Leon
Rosenberg<rosenberg.leon@googlemail.com> wrote:
> why don't you just use softreference + expiration timestamp and save
> all the trouble?
> Leon
>
> On Wed, Jun 17, 2009 at 4:07 PM, Renè Glanzer<rene.glanzer@gmail.com> wrote:
>> Hi,
>>
>> it's me again with an update.
>> the LRUMap.mapIterator() still produces the
>> ConcurrentModificationException when a call to MapIterator.remove()
>> occurs.
>>
>> Maybe this info helps
>> René
>>
>>
>> 2009/6/17 Renè Glanzer <rene.glanzer@gmail.com>:
>>> Hi Jörg,
>>>
>>> it's me again. With a smile on my face :-)
>>>
>>> I changed my code according to your hint.
>>> Now i don't use the keySet but the entrySet. With only to adopt the rest of
>>> the method to the entrySet and still
>>> calling the remove() method of the iterator in my tests no
>>> ConcurrentModificationException occured!!
>>>
>>> Additionally now I'm using the LURMap.mapIterator() which also performs well
>>> and according to the docu should be prefered over the entrySet or keySet.
>>>
>>> Now the new an well working code looks like this:
>>>
>>> public void removeAllExpiredItems()
>>>   {
>>>     synchronized(this.store)
>>>     {
>>>       MapIterator it=this.store.mapIterator(); //Here I'm using the new
>>> MapIterator
>>>       while(it.hasNext())
>>>       {
>>>         m_catLog.debug("Reading object");
>>>         Object key=it.next();
>>>         Item currentItem=(Item)it.getValue();
>>>         if(currentItem.birth==0)
>>>         {
>>>           m_catLog.debug("0 birth found for key "+key+" calling
>>> Iterator.remove");
>>>           it.remove();
>>>         }
>>>       }
>>>       this.setLastCleanDate(new Date());
>>>     }
>>>   }
>>>
>>> Thousand Thanks for your help Jörg
>>> this fixed my Problem and maybe also fixes the problems from the other
>>> people who suffered the same problem.
>>> Furthermore I'm pleased to see that the JIRA issue COLLECTION-330 is
>>> handling the problem with the keySet call.
>>>
>>> 2009/6/17 Jörg Schaible <joerg.schaible@gmx.de>
>>>>
>>>> Renè Glanzer wrote at Mittwoch, 17. Juni 2009 11:48:
>>>>
>>>> > Hi Jörg,
>>>> >
>>>> > that are great news, I'll give it a try.
>>>> > And of course I'll report my experience.
>>>>
>>>> That would be fine. Actually I opened an own JIRA issue for this now
>>>> (COLLECTION-330), COLLECTION-3 was simply too vague and had a too long
>>>> history of different symptoms.
>>>>
>>>> - Jörg
>>>>
>>>>
>>>> ---------------------------------------------------------------------
>>>> To unsubscribe, e-mail: user-unsubscribe@commons.apache.org
>>>> For additional commands, e-mail: user-help@commons.apache.org
>>>>
>>>
>>>
>>
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail: user-unsubscribe@commons.apache.org
>> For additional commands, e-mail: user-help@commons.apache.org
>>
>>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: user-unsubscribe@commons.apache.org
> For additional commands, e-mail: user-help@commons.apache.org
>
>

---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@commons.apache.org
For additional commands, e-mail: user-help@commons.apache.org


Mime
View raw message