[SWS-613] Jaxp13XPathTemplate uses thread-unsafe XPathFactory as field Created: 25/Mar/10  Updated: 04/May/12  Resolved: 11/May/10

Status: Closed
Project: Spring Web Services
Component/s: XML
Affects Version/s: 1.5.9
Fix Version/s: 2.0 M2, 1.5.10

Type: Bug Priority: Major
Reporter: Jeroen van Erp Assignee: Arjen Poutsma
Resolution: Fixed Votes: 0
Labels: None
Remaining Estimate: 0d
Time Spent: 19m
Original Estimate: Not Specified


 Description   

The XPathFactory provided by Sun in the JDK mentions it's not threadsafe, see: http://java.sun.com/javase/6/docs/api/javax/xml/xpath/XPathFactory.html. Though it is not clear from documentation nor code which of the methods is not threadsafe. It can either be:
a) The XPathFactory.newInstance(...) method: In which case Jaxp13XPathTemplate should clearly document that it should only be constructed once for an entire application to prvent concurrency bugs
b) Any of the other instance methods: In which case Jaxp13XPathTemplate should not use XPathFactory as a field if it wants to be threadsafe.

This means that at the moment the Jaxp13XPathTemplate deviates from other Spring templates, such as JdbcTemplate etc, as these are all threadsafe.



 Comments   
Comment by Arjen Poutsma [ 11/May/10 ]

Fixed in 2.0 and 1.5 branches.

Comment by Edwin Dhondt [ 15/Apr/11 ]

Arjen, can this bug be the cause for http://forum.springsource.org/showthread.php?t=107721 ?

Comment by Edwin Dhondt [ 15/Apr/11 ]

In addition to my previous content ? How can I get a hold (using Maven) of the 1.5.10 release ?

Comment by Edwin Dhondt [ 13/Apr/12 ]

Is this really fixed in the 2.0 branch because in 2.0.x Jaxp13XPathTemplate still has XPathFactory as a field: "private XPathFactory xpathFactory".

Comment by Arjen Poutsma [ 01/May/12 ]

@Edwin: Note that the createXPath() method is synchronized, and that's the only place the field is used. So yes, it is fixed.

Comment by Arjen Poutsma [ 04/May/12 ]

Closing old issues

Generated at Wed Dec 13 20:31:27 UTC 2017 using JIRA 6.4.14#64029-sha1:ae256fe0fbb912241490ff1cecfb323ea0905ca5.