commons-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Simon Raess (JIRA)" <>
Subject [jira] Commented: (JXPATH-76) CompiledExpression not completely thread-safe
Date Wed, 31 Jan 2007 19:51:05 GMT


Simon Raess commented on JXPATH-76:

I've thought about that solution too, but the change without synchronized is pretty straightforward.
Instead of lazy initialization, the initialization is simply moved to the constructor. There
are no side-effects and the need of synchronization is completely removed. The cost of synchronization
has to be paid for each expression evaluation. It is needed only on the first time. How else
can I convince you? ;-)

> CompiledExpression not completely thread-safe
> ---------------------------------------------
>                 Key: JXPATH-76
>                 URL:
>             Project: Commons JXPath
>          Issue Type: Bug
>    Affects Versions: 1.2 Final
>            Reporter: Simon Raess
>             Fix For: 1.3
>         Attachments: jxpath.patch
> Some classes in compiled expressions are not thread-safe, because they lazily initialize
some information that should be initialized at object construction. The classes I've found
are Path and ExpressionPath. I've attached a path that fixes the problem. 
> When two threads tried to initialize such an object concurrently, it was possible that
the expression was evaluated as simple expression when it should have been evaluated as complex
expression. See the two stack traces below (using xpath expression //ExternalData/Order/@id).
The first stack trace shows the bug in action, the second how it should look:
> caused by java.lang.UnsupportedOperationException: Not supported node test for attributes:
> 	at org.apache.commons.jxpath.ri.axes.SimplePathInterpreter.getNodeIterator(
> 	at org.apache.commons.jxpath.ri.axes.SimplePathInterpreter.doStepNoPredicatesStandard(
> 	at org.apache.commons.jxpath.ri.axes.SimplePathInterpreter.doStep(
> 	at org.apache.commons.jxpath.ri.axes.SimplePathInterpreter.interpretSimpleLocationPath(
Compiled Code))
> 	at org.apache.commons.jxpath.ri.compiler.Path.getSingleNodePointerForSteps(
Compiled Code))
> 	at org.apache.commons.jxpath.ri.compiler.LocationPath.computeValue(
> 	at org.apache.commons.jxpath.ri.JXPathContextReferenceImpl.getPointer(
> 	at org.apache.commons.jxpath.ri.JXPathCompiledExpression.selectSingleNode(
Compiled Code))
> This replaces the lines starting at Path.getSingleNodePointerForSteps:
>         LocationPath(Path).searchForPath(EvalContext) line: 183	
>         LocationPath(Path).getSingleNodePointerForSteps(EvalContext) line: 159	

This message is automatically generated by JIRA.
You can reply to this email to add a comment to the issue online.

To unsubscribe, e-mail:
For additional commands, e-mail:

View raw message