[ 
https://issues.apache.org/jira/browse/XERCESJ-911?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=14365466#comment-14365466
 ] 

Patrick Tucker commented on XERCESJ-911:
----------------------------------------

This seems absolutely crazy to me, I would expect that if you tried to traverse 
2 elements, where one contains the other or even the same element, by more than 
one thread at the same time issues would arise.  But, if I'm traversing 2 
completely different elements why should I expect that there be threading 
issues?  As common as threading is these days, you would think something like 
this would be possible.  Please reconsider this poor design.

Sorry for bringing this one back from the grave. :)

> Traversing the DOM throws NullPointerException
> ----------------------------------------------
>
>                 Key: XERCESJ-911
>                 URL: https://issues.apache.org/jira/browse/XERCESJ-911
>             Project: Xerces2-J
>          Issue Type: Bug
>          Components: DOM (Level 3 Core)
>    Affects Versions: 2.6.2
>         Environment: Operating System: Other
> Platform: PC
>            Reporter: Malik Hemani
>
> I'm traversing a Document parsed by the DOMParser and running into 
> NullPointerExceptions. 
> The exception occurs at 
>      org.apache.xerces.dom.ParentNode.nodeListItem(Unknown Source)
>      org.apache.xerces.dom.ParentNode.item(Unknown Source)
> Sometimes is it also seen when 'NodeList.getLength()' is called.
> The traversing is done using a for loop and recursing into the routine, 
> EXAMPLE:
> ========
> Node findNode(Node parentNode) {
> NodeList childNodes = parentNode.getChildNodes();
> for(int i = 0; i < childNodes.getLength(); i++) {
>     Node child = childNodes.item(i);
>     if (child != null && child.getNodeType != Node.ELEMENT_NODE) {
>         continue;
>     }
>     else {
>         // do something
>         ...
>         ...
>     }
> }
> // Then recursively call the above routine
> for (int i = 0; i < childNodes.getLength(); i++) {
>     Node child = childnodes.item(i);
>     
>     if (child != null) {
>         Node found = findNode(child);
>         // more code to follow
>         ...
>         ...
>     }
> }
> }
> If you need the sample XML document, I prefer to email it you.
> Thanks.



--
This message was sent by Atlassian JIRA
(v6.3.4#6332)

---------------------------------------------------------------------
To unsubscribe, e-mail: j-dev-unsubscr...@xerces.apache.org
For additional commands, e-mail: j-dev-h...@xerces.apache.org

Reply via email to