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

Jason Hunter jhunter at servlets.com
Fri Oct 26 03:18:44 PDT 2007


Yes, I'm definitely going to patch it.  It's not a trivial patch so I 
want to make sure to review it carefully, and right now I'm coding 
non-stop on another thing that's launching next week.  I appreciate you 
working up the patch and sticking with me here.

-jh-

rolf.lear at algorithmics.com wrote:
> Hi Jason.
> 
> Is there any feedback on this? I don't like pestering you but it would
> be very useful to have some idea of whether JDom is going to be patched
> in some way to fix the bug (it is at least 2 years old now). 
> 
> Thanks
> 
> Rolf
> 
> -----Original Message-----
> From: Rolf Lear 
> Sent: Wednesday, October 17, 2007 1:08 PM
> To: Rolf Lear; 'Bradley S. Huffman'; 'jhunter at servlets.com'
> Cc: 'jdom-interest at jdom.org'
> Subject: RE: [jdom-interest] Bug in ListIterator.add() method
> 
> Hi All.
> 
> I have run in to this bug (again), and notice that the fix for this bug
> is not yet committed to CVS.
> 
> The logic in the existing ContentList.ListIterator class is pretty
> complex (and broken), and it can be substantially simplified while at
> the same time fixing the problems.
> 
> I submitted the patch to do this a number of times .... but the CVS repo
> has moved on again, so, I have manually applied the patch to the latest
> CVS, and here submit the full ContentList.java source. The only changes
> are in the ListIterator subclass, which has been entirely rewritten.
> 
> In addition, I have run the tests that Christian Gruber proposed on 22
> April 2005 by compiling JDom with java 1.3.1_20, and using his test
> code.
> 
> Finally, I have run the test suite over the 1.3.1_20 jar with the fix,
> and it has passed 177 of 177 tests. I added an additional test that
> illustrates the fixed bugs, making 178 tests. These tests all pass.
> 
> Here is the additional test I incorporated in
> org.jdom.test.cases.TestFilterList
>     public void test_TCM__ListIterator_listIterator_int3() {
>         try {
>             Element r = new Element("root");
>             Document d = new Document().setRootElement(r);
>             r.addContent(new Element("element").setText("1"));
>             r.addContent(new Element("element").setText("2"));
>             r.addContent(new Element("element").setText("3"));
> 
>             Element xxx = new Element("element").setText("xxx");
>             Element yyy = new Element("element").setText("yyy");
> 
>             ListIterator i = r.getChildren("element").listIterator();
>             while (i.hasNext()) {
>                 Element e = (Element) i.next();
>                 i.add(new Element("element").setText(e.getText() +
> "_x"));
>                 i.add(new Element("element").setText(e.getText() +
> "_y")); // bug1 - double add should work
>             }
>             i.add(xxx); // bug2 - add at end of list....
>             assertEquals("previous() is not recent add()", xxx,
> i.previous());
>             i.set(yyy);
>             assertEquals("yyy not attached", r, yyy.getParent());
>             assertFalse("xxx is still attached", xxx.isAncestor(r));
>            
>             i.remove();
>            
>         } catch (OutOfMemoryError oom) {
>             System.gc();
>             oom.printStackTrace();
>             fail("ListIterator.add() caused OutOfMemory!");
>         } catch (Exception e) {
>             e.printStackTrace();
>             fail("Unable to complete ListIterator tests");
>         }
>     }
> 
> 
> Finally, the ContentList source is attached.
> 
> Rolf
> 
> 
> 
> 
> -----Original Message-----
> From: Rolf Lear 
> Sent: Tuesday, October 11, 2005 5:41 PM
> To: 'Bradley S. Huffman'; Rolf Lear
> Cc: jdom-interest at jdom.org
> Subject: RE: [jdom-interest] Bug in ListIterator.add() method
> 
> 
> Just to bump this to the top of the list again.... is this code being
> used by anyone ... it is not in CVS.
> 
> Rolf
> 
> -----Original Message-----
> From: Bradley S. Huffman [mailto:hip at a.cs.okstate.edu]
> Sent: Tuesday, May 17, 2005 10:17 AM
> To: Rolf Lear
> Cc: jdom-interest at jdom.org
> Subject: Re: [jdom-interest] Bug in ListIterator.add() method
> 
> 
> Rolf Lear writes:
> 
>> Just to confirm the status of this patch .... and rejuvenate some
> interest
>> in it.
>>
>> Has it been rejected?
> 
> No, it just seems everyone has been very, very busy. I know I have for
> the last
> year.
> 
> Brad
>  
> --------------------------------------------------------
> 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.
> --------------------------------------------------------
> 
> _______________________________________________
> 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