Bug #597
closedsaxon:evaluate() isn't thread-safe
0%
Description
SourceForge user: mhkay
The saxon:evaluate() extension function causes a static
context for the XPath expression to be established when
the containing stylesheet (or query) is compiled. This
static context is then modified, by declaring the
variables $p1..$p9, when the XPath expression is
compiled, that is, when the saxon:evaluate()
instruction is executed.
This has two adverse consequences:
(a) saxon:evaluate is not thread-safe: undefined errors
may occur if it is used in a compiled stylesheet or
query that is executed in multiple threads concurrently
(b) performance gradually degrades when a compiled
stylesheet or query containing calls to saxon:evaluate
is serially reused.
The problem applies to 8.3 and 8.2, and possibly
earlier releases.
A patch is provided. This is in two parts.
(a) replace the module net.sf.saxon.functions.Evaluate
with the new version attached.
(b) add the following method to module
net.sf.saxon.trans.IndependentContext
/**
* Create a copy of this IndependentContext. All
aspects of the context are copied
* except for declared variables.
*/
public IndependentContext copy() {
IndependentContext ic = new
IndependentContext(config);
ic.namespaces = new HashMap(namespaces);
ic.collations = new HashMap(collations);
ic.variables = new HashMap();
ic.defaultCollationName = defaultCollationName;
ic.baseURI = baseURI;
ic.locationMap = locationMap;
ic.functionLibrary = functionLibrary;
ic.defaultFunctionNamespace =
defaultFunctionNamespace;
ic.schemaImporter = schemaImporter;
ic.externalResolver = externalResolver;
return ic;
}
Files
No data to display
Please register to edit this issue