I don't know about whether DocumentBuilderFactory is not thread-safe, but
refreshDocumentBuilderFactory and getXMLDocBuilder need to be synchronized with
respect to one another, as the former assigns to the dbf member then calls
methods on it to set parsing attributes.  The assignment and attribute setting
should be atomic, right?

I've attached the trivial patch that changes getXMLDocBuilder to be
synchronized.

Scott

----- Original Message -----
From: "Emilio Belmonte" <[EMAIL PROTECTED]>
To: <[EMAIL PROTECTED]>
Sent: Thursday, May 16, 2002 3:09 PM
Subject: is SOAP thread-safe?


> I noticed that this method:
>
> XmlParserUtils.getXMLDocBuilder()
>
> is not synchronized.  According to the JAXP documentation, the
> DocumentBuilderFactory class is not thread-safe.  Is there any reason for
> not synchronizing it?
>
> Thank you,
>
> --Emilio
>
--- i:\xml-soap\java\src\org\apache\soap\util\xml\XMLParserUtils.java   Fri May 17 
07:24:12 2002
+++ i:\xml-soap\java\src\org\apache\soap\util\xml\XMLParserUtils0.java  Fri May 17 
+12:57:50 2002
@@ -130,7 +130,7 @@
    * @return DocumentBuilder an instance of a document builder, 
    * or null if a ParserConfigurationException was thrown.
    */
-  public static DocumentBuilder getXMLDocBuilder()
+  public synchronized static DocumentBuilder getXMLDocBuilder()
     throws IllegalArgumentException {
     // Step 2: create a DocumentBuilder that satisfies the constraints
     // specified by the DocumentBuilderFactory

Reply via email to