[jdom-interest] Bug in ListIterator.add() method

Rolf Lear rlear at algorithmics.com
Fri Apr 22 08:33:35 PDT 2005

The complete iterator stuff in JDom is based on pre-collections stuff. There
is a lot of scope to re-hash the iterator problem.

I'll volunteer a patch in the next couple of days if people want to see the
iterator stuff re-written. When I was looking at the Parent/Child stuff a
year or so ago I odentified the iterator processes as being a weak point in
JDom in the sense that it was just plain complex. The wayu I though I would
re-do it implied Java1.2 logic IIRC.

Anyways, I'll use the weekend to produce a patch if people want.


-----Original Message-----
From: jdom-interest-bounces at jdom.org
[mailto:jdom-interest-bounces at jdom.org]On Behalf Of Bradley S. Huffman
Sent: Friday, April 22, 2005 10:57 AM
To: Christian Gruber
Cc: jdom-interest at jdom.org
Subject: Re: [jdom-interest] Bug in ListIterator.add() method

Christian Gruber writes:

> As I suppose, Jdoms ListIterator.add() implementation has a problem
> when it is called more than once and when it is called at the end of
> the list.

Looking at the code it looks like the sequence

    listIterator.add(new Element("a"));
    listIterator.add(new Element("b"));
    listIterator.add(new Element("c"));

will produce <c><b><a> instead of <a><b><c> and continue iterating on
element 2 (<b>) instead of after the last new element. That is a bug.

To control your jdom-interest membership:

This email and any files transmitted with it are confidential and
proprietary to Algorithmics Incorporated and its affiliates
("Algorithmics").  If received in error, use is prohibited.  Please destroy,
and notify sender.  Sender does not waive confidentiality or privilege.
Internet communications cannot be guaranteed to be timely, secure, error or
virus-free.  Algorithmics does not accept liability for any errors or
omissions.  Any commitment intended to bind Algorithmics must be reduced to
writing and signed by an authorized signatory.

More information about the jdom-interest mailing list