Project

Profile

Help

Bug #3721

closed

net.sf.saxon.tree.linked.ParentNodeImpl.insertChildren

Added by John Francis about 6 years ago. Updated almost 6 years ago.

Status:
Closed
Priority:
Normal
Assignee:
Category:
Internals
Sprint/Milestone:
-
Start date:
2018-03-15
Due date:
% Done:

100%

Estimated time:
Legacy ID:
Applies to branch:
9.8, trunk
Fix Committed on Branch:
9.8, trunk
Fixed in Maintenance Release:
Platforms:

Description

I am attempting to construct am XdmNode tree from Java.

At some point I wish to populate sibling elements in separate threads concurrently, so I do not think the net.sf.saxon.event.Builder approach will work for me.

I therefore have used Linked Tree classes directly. I suppose that using TinyTreeBuilder I could create separate trees and then use TinyTreeBuilder.bulkCopy, which I am exploring now.

However when using LinkedTree classes I found a problem.

If net.sf.saxon.tree.linked.ParentNodeImpl.insertChildren is called for the first time with an Array of child ElementImpl it just copies the array into the children member and does not call cleanUpChildren.

As a consequence the parent and sibling "pointers" are not set. I can set the parent of the children manually, but setting the sibling pointer seems to be a job which is meant to be done by ParentNodeImpl.

So when I serialize the LinkedTree the Serializer goes into infinite recursion.

Attached is a trivial Java program to reproduce the problem. When run without arguments it adds a single child ElementImpl first to the parent, then adds the tail of the array.

When run with the single argument other than 'well' e.g. badly, it adds the child ElementImpls in one go and goes into infinite recursion during serialization.

What is the correct way to create lists of child ElementImpls to avoid this?

Am I approaching things the wrong way?

Would I be better off using TinyTreeBuilder (smaller memory size) and bulkCopy?


Files

SaxonLinkedTreeSample.java (2.98 KB) SaxonLinkedTreeSample.java Java cmd line app to reproduce the problem. (Run with arg 'badly' to cause bug) John Francis, 2018-03-15 11:22

Please register to edit this issue

Also available in: Atom PDF