Bug #6425
closed![Author: lu zhang](https://www.gravatar.com/avatar/88522955ab3a4255009201dfdaa9ef45?rating=PG&size=50&default=https%3A%2F%2Fassets.plan.io%2Fimages%2Fdefault_avatar.png)
![Assignee: Michael Kay](https://www.gravatar.com/avatar/db6526d63053f09b62e52c2da8b2230a?rating=PG&size=22&default=https%3A%2F%2Fassets.plan.io%2Fimages%2Fdefault_avatar.png)
When the saxon:thread attribute is set for xsl:for-each in saxon-ee-12.4 (enterprise edition), NullPointException and ClassCastException occasionally occur in multi-thread scenarios.
0%
Description
When the saxon:thread attribute is set for xsl:for-each in saxon-ee-12.4 (enterprise edition), NullPointException and ClassCastException occasionally occur in multi-thread scenarios.
Caused by: java.lang.NullPointerException at net.sf.saxon.expr.XPathContextMajor.getTargetComponent(XPathContextMajor.java:684) at net.sf.saxon.expr.instruct.ApplyTemplates.getTargetMode(ApplyTemplates.java:303) at net.sf.saxon.expr.instruct.ApplyTemplates$ApplyTemplatesElaborator.lambda$elaborateForPush$1(ApplyTemplates.java:613) at net.sf.saxon.expr.instruct.Block$BlockElaborator.lambda$elaborateForPush$4(Block.java:895) at net.sf.saxon.expr.instruct.TemplateRule.applyLeavingTail(TemplateRule.java:376)
or
Caused by: java.lang.ClassCastException: net.sf.saxon.expr.Component cannot be cast to net.sf.saxon.expr.Component$M at net.sf.saxon.expr.instruct.ApplyTemplates.getTargetMode(ApplyTemplates.java:303) at net.sf.saxon.expr.instruct.ApplyTemplates$ApplyTemplatesElaborator.lambda$elaborateForPush$1(ApplyTemplates.java:613) at net.sf.saxon.expr.instruct.Block$BlockElaborator.lambda$elaborateForPush$4(Block.java:895) at net.sf.saxon.expr.instruct.TemplateRule.applyLeavingTail(TemplateRule.java:376)
Cause: processComponentReference method of net.sf.saxon.expr.instruct.Actor
int slot = bindings.size();
ComponentBinding cb = new ComponentBinding(name, target);
bindings.add(cb);
invocation.setBindingSlot(slot);
The operation of obtaining the slot and adding the slot to the bindings is not an atomic operation. In the multi-thread scenario, the positions of the slot and bindings may be mismatched or overwritten.
Solution (s): Ensure that the slot obtaining and adding operations are atomic and the performance in multi-thread scenarios is ensured.:
Related issues
Please register to edit this issue