If you call remove() on one FilterList of an element's ContentList, then any other FilterLists should 're-sync' when they are next used, but this is not happening....
I see that I have 6 elements as expected in my list. None are null.
I am basically then trying to find a matching related element id in that list using something like:
Element found = null;
ListIterator<?> iter = documentVersionElements .listIterator();
while( iter.hasNext() ) {
Element checkElement = (Element)iter.next();
EsfUUID evParentId = new EsfUUID(checkElement.getChildText("documentId", ns));
if ( evParentId.equals(id) ) {
found = checkElement;
break;
}
}
Then, assuming I find it (found != null), I process it as expected. But I then want to remove the found element from the element list so it cannot be found again, so I use this:
documentVersionElements.remove(found);
Most of the time, this seems to work as expected, and the documentVersionElements list is then shorter by 1. But there are times when a list of 6 elements remains 6 elements after the remove (and remove() returns false), with 4 of them now null (not removed, but actually a null element), so in when I return to the listIterator() above and get my next() element, the element is null.
It's as if my Element objects are not unique in the list in terms of equals/hashCode as my elements should never be nulled out.
I am not sure why an element I find by iterating cannot then be removed. How could it fail to remove? Why would it change other list elements to NULL instead? Is this not a valid usage pattern?
Thanks,
David
The text was updated successfully, but these errors were encountered:
If you call remove() on one FilterList of an element's ContentList, then any other FilterLists should 're-sync' when they are next used, but this is not happening....
From the original report: http://markmail.org/message/bf4sf6g52gil3jva
I believe I've run into a problem that I don't think I had with JDOM 1.1.3 before I upgraded to 2.0.1.
I create a list of elements of a selected element using:
List<?> documentVersionElements = rootElement.getChildren("DocumentVersion", ns);
I see that I have 6 elements as expected in my list. None are null.
I am basically then trying to find a matching related element id in that list using something like:
Then, assuming I find it (found != null), I process it as expected. But I then want to remove the found element from the element list so it cannot be found again, so I use this:
documentVersionElements.remove(found);
Most of the time, this seems to work as expected, and the documentVersionElements list is then shorter by 1. But there are times when a list of 6 elements remains 6 elements after the remove (and remove() returns false), with 4 of them now null (not removed, but actually a null element), so in when I return to the listIterator() above and get my next() element, the element is null.
It's as if my Element objects are not unique in the list in terms of equals/hashCode as my elements should never be nulled out.
I am not sure why an element I find by iterating cannot then be removed. How could it fail to remove? Why would it change other list elements to NULL instead? Is this not a valid usage pattern?
Thanks,
David
The text was updated successfully, but these errors were encountered: