[jdom-interest] From B7 to B8 - ConcurrentModificationException

Bilton, Sasha Sasha.Bilton at bskyb.com
Mon Mar 18 06:50:40 PST 2002


Hi,

I've just converted from Beta 7 to Beta 8 RC1 and I've got the following
exception coming up now...

Exception in thread "main" java.util.ConcurrentModificationException
        at
org.jdom.ContentList$FilterListIterator.checkConcurrentModification(C
ontentList.java:1206)
        at
org.jdom.ContentList$FilterListIterator.hasNext(ContentList.java:928)
<snip>

from this code

  public void removeUnit(Unit unit)
  {
    String unitName = unit.getName();

    Iterator i = getUnits().iterator();
    while (i.hasNext())				
    {
      Element e = (Element)i.next();
      if(e.getTextTrim().equals(unitName))
      {
        values.removeContent(e);
      }
    }
  }

Where getUnits() returns a List of Elements, from the variable values that
have a single text value.

I guess that the error is occuring because I'm removing elements from
'values' at the same time as going through 'values' iterator. What's weird
is that the error is occuring under B8 and not B7. 

Any hints on the best way to fix it and why it happening now would be a
great help,
thanks

Sasha


**********************************************************************
Information in this email is confidential and may be privileged. 
It is intended for the addressee only. If you have received it in error,
please notify the sender immediately and delete it from your system. 
You should not otherwise copy it, retransmit it or use or disclose its
contents to anyone. 
Thank you for your co-operation.
**********************************************************************




More information about the jdom-interest mailing list