[jdom-interest] Bug in Document(List) -> setMixedContent()

philip.nelson at omniresources.com philip.nelson at omniresources.com
Mon Jun 25 21:28:02 PDT 2001


> >                 if (oldRoot != null) { //*******************
> >                         content = oldContent;
> >                         oldRoot.setDocument(this);
> >                         // Unmodify all modified elements.  
> DO NOT change
> 
> I did a more limited if clause.  Yours appears to wrap all logic, but
> shouldn't it just wrap the oldRoot.setDocument()?

It occured to me that if there wasn't an old root element, there probably
isn't going to be any content either.  Perhaps this will change depending on
how we resolve the unhappy state discussion.


> 
> > I also patched Document(List, DocType)to throw an NPE if 
> the list is null
> > which would result in an invalid state. I suppose the NPE 
> is arguable but
> > this is better than returning a useless document.
> > 
> >     public Document(List content, DocType docType) {
> >             if (content == null)
> >                     throw new NullPointerException();
> > 
> >         setMixedContent(content);
> >         setDocType(docType);
> >     }
> 
> Whether or not you can have a truly empty doc is not really decided.

We'll wait then.  With this update my tests run 7 failures our of 150 tests.
Most of those failures have to do with nulls or bad data.  

Progess ;-)



More information about the jdom-interest mailing list