|
[
Permlink
| « Hide
]
Jayachandra Sekhara Rao Sunkara added a comment - 20/Dec/05 02:51 PM
Attaching TestSOAPEnvelope.java that depicts the scenario when the described exception is produced.
When I delved inside the source, I realized that the problem is cropping up because of logic inside NodeImpl.setParent(...) method. Here is the explanation and a suggested patch.
******* The current NodeImpl.setParent() code looks like follows... ln 1 /** ln 2 * Set the parent node and invoke appendChild(this) to ln 3 * add this node to the parent's list of children. ln 4 * @param parent ln 5 * @throws SOAPException ln 6 */ ln 7 protected void setParent(NodeImpl parent) throws SOAPException { ln 8 if (this.parent == parent) { ln 9 return; ln 10 } ln 11 if (this.parent != null) { ln 12 this.parent.removeChild(this); ln 13 } ln 14 if (parent != null) { ln 15 parent.appendChild(this); ln 16 } ln 17 this.setDirty(); ln 18 this.parent = parent; ln 19 } There is a sly bug in this code. At line 12 <code>this</code> (lets denote it as NODE_C) node is removed as a child from its existing parent (lets call this parent as NODE_P) but the link of NODE_C.parent still points to NODE_P. Because of this later when <code>appendChild</code> method is called at ln15 with NODE_C sent as the parameter, within the code of appendChild since there is going to be a detachNode call on NODE_C that call is going to fail as NODE_C claims it has a non-null parent (NODE_P) but NODE_P list of children list doesn't contain NODE_C. So I'm suggesting the following patch ln 11 if (this.parent != null) { ln 12 this.parent.removeChild(this); ln 12a this.parent = null; //remove all old lineage traces from both sides ln 12b //so that future appendChild()/detachNode() doesn't crib ln 13 } ********* I've tested the patch and found that it doesn't break any existing scenarios. I'll check this in EOD today unless someone has any objection. attaching suggested patch in a diff format.
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||