Author: mrglavas
Date: Sat May 14 17:21:42 2011
New Revision: 1103164

URL: http://svn.apache.org/viewvc?rev=1103164&view=rev
Log:
Fixing JIRA Issue #1421: http://issues.apache.org/jira/browse/XERCESJ-1421. We 
were calling previousSibling() when the node was in an inconsistent state, 
which would return the last child instead of null when the first child is being 
removed. We were just lucky to get the correct result from 
checkNormalizationAfterRemove(). Now it works by design and should be slightly 
faster when we're removing the first child. Patch thanks to Ludger Bünger. Also 
thanks to Thiwanka Somasiri for helping to investigate this issue and 
evaluating Ludger's patch.

Modified:
    xerces/java/trunk/src/org/apache/xerces/dom/ParentNode.java

Modified: xerces/java/trunk/src/org/apache/xerces/dom/ParentNode.java
URL: 
http://svn.apache.org/viewvc/xerces/java/trunk/src/org/apache/xerces/dom/ParentNode.java?rev=1103164&r1=1103163&r2=1103164&view=diff
==============================================================================
--- xerces/java/trunk/src/org/apache/xerces/dom/ParentNode.java (original)
+++ xerces/java/trunk/src/org/apache/xerces/dom/ParentNode.java Sat May 14 
17:21:42 2011
@@ -502,6 +502,9 @@ public abstract class ParentNode
 
         // notify document
         ownerDocument.removingNode(this, oldInternal, replace);
+        
+        // Save previous sibling for normalization checking.
+        final ChildNode oldPreviousSibling = oldInternal.previousSibling();
 
         // update cached length if we have any
         if (fNodeListCache != null) {
@@ -513,7 +516,7 @@ public abstract class ParentNode
                 // move the cache to its (soon former) previous sibling
                 if (fNodeListCache.fChild == oldInternal) {
                     fNodeListCache.fChildIndex--;
-                    fNodeListCache.fChild = oldInternal.previousSibling();
+                    fNodeListCache.fChild = oldPreviousSibling;
                 } else {
                     // otherwise just invalidate the cache
                     fNodeListCache.fChildIndex = -1;
@@ -544,9 +547,6 @@ public abstract class ParentNode
             }
         }
 
-        // Save previous sibling for normalization checking.
-        ChildNode oldPreviousSibling = oldInternal.previousSibling();
-
         // Remove oldInternal's references to tree
         oldInternal.ownerNode       = ownerDocument;
         oldInternal.isOwned(false);



---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to