You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@commons.apache.org by Alp Şehiç <al...@sayyazilim.com> on 2004/12/13 19:54:12 UTC

about LRUMap usage...

Hi there,

at the time I'm facing with a problem on the usage of LRUMap, so in the 
code below;

final MapIterator mapIt = map.mapIterator(); // map is a LRUMap instance...
            final TreeMap treeMap = new TreeMap();
            while (mapIt.hasNext())
            {
                if 
(mapIt.next().toString().endsWith("_DEPARTMENT_NAME")) // EXCEPTION IS 
THROWN RIGHT HERE...
                {
                    int temp =
                        Integer.parseInt(
                            mapIt.getKey().toString().substring(0, 4));
                    if (temp >= getFirstNo() && temp <= getLastNo())
                    {
                        treeMap.put(mapIt.getKey(), mapIt.getValue());
                    }
                }
            }

I'm getting :

java.lang.ExceptionInInitializerError: 
java.util.ConcurrentModificationException
    at 
org.apache.commons.collections.map.AbstractLinkedMap$LinkIterator.nextEntry(AbstractLinkedMap.java:555)
    at 
org.apache.commons.collections.map.AbstractLinkedMap$LinkMapIterator.next(AbstractLinkedMap.java:367)
    at Support.initParameters(Support.java:486)
    at Support.<clinit>(Support.java:72)
    at Store..<clinit>(Magaza.java:52)

so is there something wrong with my usage ? 
thanx in advance...



Re: about LRUMap usage...

Posted by Stephen Colebourne <sc...@btopenworld.com>.
This MAY be due to the treeMap.put(). You are not
allowed to change a map object while you are iterating
over it except via the setValue() method on the
iterator.

Stephen

 --- Alp Şehiç <al...@sayyazilim.com> wrote: 
> Hi there,
> 
> at the time I'm facing with a problem on the usage
> of LRUMap, so in the 
> code below;
> 
> final MapIterator mapIt = map.mapIterator(); // map
> is a LRUMap instance...
>             final TreeMap treeMap = new TreeMap();
>             while (mapIt.hasNext())
>             {
>                 if 
>
(mapIt.next().toString().endsWith("_DEPARTMENT_NAME"))
> // EXCEPTION IS 
> THROWN RIGHT HERE...
>                 {
>                     int temp =
>                         Integer.parseInt(
>                            
> mapIt.getKey().toString().substring(0, 4));
>                     if (temp >= getFirstNo() && temp
> <= getLastNo())
>                     {
>                         treeMap.put(mapIt.getKey(),
> mapIt.getValue());
>                     }
>                 }
>             }
> 
> I'm getting :
> 
> java.lang.ExceptionInInitializerError: 
> java.util.ConcurrentModificationException
>     at 
>
org.apache.commons.collections.map.AbstractLinkedMap$LinkIterator.nextEntry(AbstractLinkedMap.java:555)
>     at 
>
org.apache.commons.collections.map.AbstractLinkedMap$LinkMapIterator.next(AbstractLinkedMap.java:367)
>     at Support.initParameters(Support.java:486)
>     at Support.<clinit>(Support.java:72)
>     at Store..<clinit>(Magaza.java:52)
> 
> so is there something wrong with my usage ? 
> thanx in advance...
> 
> 
>  

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