From jdom at tuis.net Fri Jun 7 11:48:47 2013 From: jdom at tuis.net (jdom) Date: Fri, 07 Jun 2013 14:48:47 -0400 Subject: [jdom-interest] XPathExpression question In-Reply-To: <1C8985E6271A2E4AAD3D9F2C5BEE5E9031FEFFC0B5@RTL-MAIL01.Integ.Local> References: <1C8985E6271A2E4AAD3D9F2C5BEE5E9031FEFFC0B5@RTL-MAIL01.Integ.Local> Message-ID: Hi Wayne. You are asking in the right place.... :) Other people may provide an answer sooner, but, I suspect that I will have to study your question in detail (and reproduce some things to check). I will do that this evening (EST) and get back to you (I am at a conference now). Rolf On 2013-06-07 14:35, Keeney, Wayne wrote: > Here's hoping this question gets to the right place. > > We are using JDOM2 (2.0.3) and it's my understanding that instances > of > XPathExpression are not thread safe. We were using clone as a > (hopefully) more efficient method of getting our "own" instance of a > pre compiled XPathExpression safe from other thread access. This is > not my main question, but is it more efficient? > > My main question has to do with setting variables on the > XPathExpression. I could not get the variable setting to work on a > cloned copy of an XPathExpression, but it works if I set the variable > before cloning. The problem with this, is of course, thread safety. > > Is this a known bug, maybe fixed? > > This works (but opens an opportunity for threading problems since > we're using precompiled static instances): > > XPathExpression xPath = _pathMap_.get(method); > > xPath.setVariable("variable", _namespace_, "fString"); > > List elems = xPath.clone().evaluate(model.asDocument()); > > But this doesn't work, it doesn't seem to recognize the variable > replacement: > > XPathExpression xPath = _pathMap_.get(method).clone(); > > xPath.setVariable("variable", _namespace_, "fString"); > > List elems = xPath.evaluate(model.asDocument()); > > pathmap is just a map of precompiled XPathExpressions. > > Thanks, > > Wayne Keeney > > SAT Services