ant-notifications mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From hi...@apache.org
Subject svn commit: r747794 - /ant/ivy/core/trunk/src/java/org/apache/ivy/util/XMLHelper.java
Date Wed, 25 Feb 2009 14:26:55 GMT
Author: hibou
Date: Wed Feb 25 14:26:55 2009
New Revision: 747794

URL: http://svn.apache.org/viewvc?rev=747794&view=rev
Log:
IVYDE-35:
 - The sax parser factory is using the context classloader to load the xml parser, so make
it instanciated in the asking thread (so in the method) rather than in the class loading (in
the static blocks)

Modified:
    ant/ivy/core/trunk/src/java/org/apache/ivy/util/XMLHelper.java

Modified: ant/ivy/core/trunk/src/java/org/apache/ivy/util/XMLHelper.java
URL: http://svn.apache.org/viewvc/ant/ivy/core/trunk/src/java/org/apache/ivy/util/XMLHelper.java?rev=747794&r1=747793&r2=747794&view=diff
==============================================================================
--- ant/ivy/core/trunk/src/java/org/apache/ivy/util/XMLHelper.java (original)
+++ ant/ivy/core/trunk/src/java/org/apache/ivy/util/XMLHelper.java Wed Feb 25 14:26:55 2009
@@ -39,10 +39,6 @@
 
 public abstract class XMLHelper {
 
-    private static final SAXParserFactory VALIDATING_FACTORY = SAXParserFactory.newInstance();
-
-    private static final SAXParserFactory FACTORY = SAXParserFactory.newInstance();
-
     static final String JAXP_SCHEMA_LANGUAGE 
         = "http://java.sun.com/xml/jaxp/properties/schemaLanguage";
 
@@ -58,18 +54,16 @@
 
     private static DocumentBuilder docBuilder;
     
-    static {
-        VALIDATING_FACTORY.setNamespaceAware(true);
-        VALIDATING_FACTORY.setValidating(true);
-    }
-
     private static SAXParser newSAXParser(URL schema, InputStream schemaStream)
             throws ParserConfigurationException, SAXException {
         if (!canUseSchemaValidation || schema == null) {
-            return FACTORY.newSAXParser();
+            return SAXParserFactory.newInstance().newSAXParser();
         }
         try {
-            SAXParser parser = VALIDATING_FACTORY.newSAXParser();
+            SAXParserFactory parserFactory = SAXParserFactory.newInstance();
+            parserFactory.setNamespaceAware(true);
+            parserFactory.setValidating(true);
+            SAXParser parser = parserFactory.newSAXParser();
             parser.setProperty(JAXP_SCHEMA_LANGUAGE, W3C_XML_SCHEMA);
             parser.setProperty(JAXP_SCHEMA_SOURCE, schemaStream);
             parser.getXMLReader().setFeature(XML_NAMESPACE_PREFIXES, true);
@@ -79,7 +73,7 @@
                 "WARNING: problem while setting JAXP validating property on SAXParser...
"
                 + "XML validation will not be done: " + ex.getMessage());
             canUseSchemaValidation = false;
-            return FACTORY.newSAXParser();
+            return SAXParserFactory.newInstance().newSAXParser();
         }
     }
 



Mime
View raw message