[jdom-interest] conncurrent modification exception with jdom 8

Bradley S. Huffman hip at a.cs.okstate.edu
Fri Dec 20 18:19:34 PST 2002


See the FAQ for a example of why ConcurrentModificationException is thrown.

Content lists are "live" in Beta 8 (see Element.setContent for a description
of "live").  I'm only guessing but is getNodesFromXML somehow returning, in
a round about way, either

    sqlXmlDoc.getRootElement().getContent() or
    sqlXmlDoc.getRootElement().getChildren()

If it is, then the addContent in the iterator loop will cause the exception
on the next call to hasNext() or next().

Brad

"Carey Boldenow" writes:

> I recently upgraded from build 7 to build 8 and one of my 
> methods is now throwing a 
> java.util.ConcurrentModificationException where it 
> previously did not (see stacktrace below). I have also 
> included the method that is throwing the exception. Thanks 
> for any help offered.
> 
> java.util.ConcurrentModificationException
> 	at 
> org.jdom.ContentList$FilterListIterator.checkConcurrentModification(ContentLi
> st.java:1230)
> 	at 
> org.jdom.ContentList$FilterListIterator.hasNext(ContentList.java:942)
> 	at 
> com.cytera.frameworks.database.SqlXmlDocumentManager.buildSqlXmlDocument(SqlX
> mlDocumentManager.java:86)
> 	at 
> com.cytera.frameworks.database.ConnPoolJuggler.init(ConnPoolJuggler.java:474)
> 
> 
>   public Document buildSqlXmlDocument(ArrayList 
> xmlDocPaths) {
>          sqlXmlDoc = new Document(new 
> Element("SQL-STATEMENTS"));
>          try {
>              for (int i=0; i<xmlDocPaths.size(); i++) {
>                  List list = 
> getNodesFromXML((String)xmlDocPaths.get(i));
>                  Iterator iter = list.iterator();
>                  while (iter.hasNext()) { //Exception is 
> thrown here
>                      sqlXmlDoc.getRootElement().addContent(((Element)iter.nex
> t()).detach());
>                  }
>              }
>          }
>          catch(Exception e) {
>              e.printStackTrace();
>          }
>          return sqlXmlDoc;
>      }
> _______________________________________________
> To control your jdom-interest membership:
> http://lists.denveronline.net/mailman/options/jdom-interest/youraddr@yourhost
> .com



More information about the jdom-interest mailing list