You are viewing a plain text version of this content. The canonical link for it is here.
Posted to j-dev@xerces.apache.org by "A.S.Thiwanka Somasiri (JIRA)" <xe...@xml.apache.org> on 2011/02/10 11:10:57 UTC

[jira] Commented: (XERCESJ-1421) Temporary inconsistent data inside Xerces2-J when removing a first child of a node.

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

A.S.Thiwanka Somasiri commented on XERCESJ-1421:
------------------------------------------------

@ line 547 and 548 in Class org.apache.xerces.dom.ParentNode.java:

// Save previous sibling for normalization checking.
ChildNode oldPreviousSibling = oldInternal.previousSibling();

Assuming the case that (oldInternal == firstChild):

When it comes to this point the oldInternal.isFirstChild(false) is already invoked and now it is not available as the first child. When it was acting as the first child it contained null value in ChildNode.previousSibling. An, when it comes to line 548, it fails isFirstChild() (when calling oldInternal.previousSibling()). But the return value is going to be a null as well. At this point oldInternal.previousSibling() always return a null value once oldInternal was a first child && now it is not. So I think the code does have ant defect.

Pls correct me if I have misunderstood the issue.

Thanks.

> Temporary inconsistent data inside Xerces2-J when removing a first child of a node.
> -----------------------------------------------------------------------------------
>
>                 Key: XERCESJ-1421
>                 URL: https://issues.apache.org/jira/browse/XERCESJ-1421
>             Project: Xerces2-J
>          Issue Type: Improvement
>          Components: DOM (Level 3 Core)
>    Affects Versions: 2.9.1
>            Reporter: Ludger Bünger
>            Priority: Minor
>         Attachments: PreviousSiblingInconsistentDataPatch.txt
>
>
> When removing a first child, currently there is a local field inside ParentNode.internalRemoveChild that contains inconsistent data.
> Since in this specific case the following code still performs correct, there is currently no harm done.
> However I think it should be fixed nonetheless since future changes to the code might cause problems.
> And here the description of the issue:
> Xerces2-J uses an internal optimization by overloading the ChildNode.previousSibling field.
> 1) If a node has a previous sibling, this field contains the previous sibling.
> 2) if a node is the first child of it's parent (and thus has no previous sibling), this field is re-used for a different purpose and contains the last sibling thus allowing quick access to the end of a node list
> Now ChildNode.internalRemoveNode stores a reference to the previousSibling of the removed node for normalization checking purposes in the local field oldPreviousSibling.
> However this is done after removal of the node is already done but before null'ing of the tree structure fields of the node.
> Since this node has already been removed, the isFirstChild() check fails and instead of 'null' the last sibling is stored in the oldPreviousSibling field.
> By chance the normalization checking code still works correct if the previous sibling field contains the last sibling instead of the correct value 'null' but this still should be fixed.
> See attached patch.

-- 
This message is automatically generated by JIRA.
-
For more information on JIRA, see: http://www.atlassian.com/software/jira

       

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