[jdom-interest] java.util.ConcurrentModificationException
Bradley S. Huffman
hip at a.cs.okstate.edu
Thu Jun 9 07:42:35 PDT 2005
I'm see you have two iterators, listxpp and listxpp2, that you are using
at the same time. I assume they have the same backing list. The problem
is a call to hasNext() on the first that returns true is giving a guarantee
that a corresponding call to next() will return a valid object. In general
allowing two iterator to modify the same backing list at the same time, or
even one to modify while the other just transverses, could break this
guarantee. So most java iterators don't allow it.
Brad
"X.P.Pratibha :-)" writes:
> Hi all,
> I am having a ListIterator to traverse my JDOM. When I find a
> list of my interest I am removing it using remove()...Its throwing
> ConcurrentModificationException..Any thoughts will be of great help.
> Please tell me whats going wrong???
>
> while(listxpp.hasNext())
> {
> int removecount=0;
> Element FWnode = ((Element)
> listxpp.next()).getChild("FirewallRule");
> String ID =FWnode.getAttributeValue("id");
>
> while(listxpp2.hasNext())
> {
> Element FWnode2 = ((Element) listxpp2.next()).getChild(
> "FirewallRule");
> String ID2 = FWnode2.getAttributeValue("id");
>
> if(ID.equals(ID2))
> {
> removecount++;
> if(removecount>1)
> {
>
>
> listxpp2.remove();
> }
> }
> }
>
> while(listxpp2.hasPrevious()){
> Element PWnode = ((Element)
> listxpp2.previous()).getChild("FirewallRule");
> }
> }
> _______________________________________________
> To control your jdom-interest membership:
> http://www.jdom.org/mailman/options/jdom-interest/youraddr@yourhost.com
More information about the jdom-interest
mailing list