< prev index next >

test/javax/xml/jaxp/unittest/common/TransformationWarningsTest.java

Print this page

        

@@ -78,11 +78,16 @@
     Transformer createTransformer() throws Exception {
         // Prepare sources for transormation
         Source xslsrc = new StreamSource(new StringReader(xsl));
 
         // Create factory and transformer
-        TransformerFactory tf = TransformerFactory.newInstance();
+        TransformerFactory tf;
+        // newTransformer() method doc states that different transformer
+        // factories can be used concurrently by different Threads.
+        synchronized (TransformerFactory.class) {
+            tf = TransformerFactory.newInstance();
+        }
         Transformer t = tf.newTransformer(xslsrc);
 
         // Set URI Resolver to return the newly constructed xml
         // stream source object from xml test string
         t.setURIResolver((String href, String base) -> new StreamSource(new StringReader(xml)));
< prev index next >