commons-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Jack, Paul" <pj...@sfaf.org>
Subject RE: [Collections] Bug or Feature? - SequencedHashMap iterators do not throw ConcurrentModificationExceptions
Date Wed, 08 May 2002 19:51:02 GMT
Is there any conceptual difference between SequencedHashMap and the
jdk1.4 LinkedHashMap?  You might want to look at the source for the java
class to see how it handles these issues of concurrent modification and
infinite iterations and such.

Might be helpful.

-Paul

-----Original Message-----
From: Michael A. Smith [mailto:mas@apache.org]
Sent: Wednesday, May 08, 2002 12:42 PM
To: Jakarta Commons Developers List; morgand@apache.org
Subject: Re: [Collections] Bug or Feature? - SequencedHashMap iterators
do not throw ConcurrentModificationExceptions


On Wed, 8 May 2002, Morgan Delagrange wrote:
> Making a modification-resistant iterator might be a
> little tricky.  E.g. what happens when, while
> iterating over a keySet, you iterate a, then remove a,
> and readd it later in the iteration?  A set iteration 
> with duplicates?  :)

yes, definately a bug.  

> > I assume your get looks like this:
> > 
> >   public Object get(Object key) {
> >     // need explicit check for contains so we don't
> > add in a mapping to
> >     // null if a mapping to null didn't exist
> > before.
> >     if(!contains(key)) return null;
> > 
> >     Object value = remove(key);
> >     put(key, value);
> > 
> >     return value;
> >   }
> 
> Yep, except that the containsKey() check is still in
> my notes, not in CVS.

I'll add it.  :)

> > and something is iterating and calling get within
> > the iterator...  
> 
> Right, it's the testSequenceMap test in your
> TestSequencedHashMap class.  I overrode it in my
> TestHashMap subclass just to avoid the infinite loop;
> you'll want to comment my override out.

ok.

michael


--
To unsubscribe, e-mail:
<mailto:commons-dev-unsubscribe@jakarta.apache.org>
For additional commands, e-mail:
<mailto:commons-dev-help@jakarta.apache.org>

--
To unsubscribe, e-mail:   <mailto:commons-dev-unsubscribe@jakarta.apache.org>
For additional commands, e-mail: <mailto:commons-dev-help@jakarta.apache.org>


Mime
View raw message