[jdom-interest] ConcurrentModificationException - why?
Robert Koberg
rob at koberg.com
Fri Dec 13 13:53:40 PST 2002
Hi,
The code below causes a ConcurrentModificationException. I don't see how the
iterators are overlapping. Can somebody see my error or tell me how I can
replace a list of elements?
Thanks for any advice,
-Rob
-oOo-
private void updateFocusedItemColumns(HttpServletRequest req, LsbProject proj,
HttpSession http_session) {
try {
Element change = getChangeElement(req.getParameter("xml_out"));
Element config = getSiteConfigElement(proj);
Element elem = getFocusElem(req.getParameter("lsb_focus"), config);
removeColumns(elem);
addColumns(elem, change);
} catch (IOException ioe) {
error stuff...
}
}
private Element getFocusElem(String focus_id, Element orig) {
List children = orig.getChildren();
for (Iterator i = children.iterator(); i.hasNext();) {
Element elem = (Element)i.next();
String id = elem.getAttributeValue("id");
if (focus_id.equals(id)) {
return elem;
} else if (elem.hasChildren()) {
Element _elem = getFocusElem(focus_id, elem);
if (_elem!=null) return _elem;
}
}
return null;
}
private void removeColumns(Element elem) {
List cols = elem.getChildren("col");
for (Iterator i = cols.iterator(); i.hasNext();) {
Element col = (Element)i.next();
elem.removeContent(col);
}
}
private void addColumns(Element elem, Element add_elem) {
List new_cols = add_elem.getChildren("col");
for (Iterator i = new_cols.iterator(); i.hasNext();) {
Element col = (Element)i.next();
elem.addContent(col);
}
}
More information about the jdom-interest
mailing list