Note that it is not just XPath. Pretty much all of the XML parsers in the
JDK are not thread safe. For instance, we were just having a related
discussion here in another thread and, at the moment, I am using ThreadLocal
to hold on instances of SAXParser for different threads.

On Fri, Aug 13, 2010 at 9:35 AM, Claus Ibsen <claus.ib...@gmail.com> wrote:

> On Fri, Aug 13, 2010 at 2:08 PM, Yiannis Mavroukakis
> <imavrouka...@gameaccount.com> wrote:
> > I have two XPath expressions on a @RoutingSlip bean, I've noticed in the
> > logs that I get this
> >
> > [    New I/O server worker #1-1] XPathBuilder                   DEBUG
> > Creating default XPathFactory
> > [    New I/O server worker #1-1] XPathBuilder                   DEBUG
> > Creating default XPathFactory
> >
> > Does this mean that there are two XPathBuilder instances ?
> >
>
> All the XPath stuff in the JDK is not thread safe and you gotta create
> new instances of the factory.
>
> The XPathFactory class is not thread-safe. In other words, it is the
> application's responsibility to ensure that at most one thread is
> using a XPathFactory object at any given moment. Implementations are
> encouraged to mark methods as synchronized to protect themselves from
> broken clients.
>
>
> >
> > Thanks,
> > Yiannis
> >
>
>
>
> --
> Claus Ibsen
> Apache Camel Committer
>
> Author of Camel in Action: http://www.manning.com/ibsen/
> Open Source Integration: http://fusesource.com
> Blog: http://davsclaus.blogspot.com/
> Twitter: http://twitter.com/davsclaus
>

Reply via email to