changeset 1132:55ff50f30ce4

8029837: NPE seen in XMLDocumentFragmentScannerImpl.setProperty since 7u40b33 Reviewed-by: joehw
author aefimov
date Tue, 22 Jul 2014 22:06:30 +0400
parents 533a5243e486
children 89117e4403e6
files src/com/sun/org/apache/xerces/internal/impl/xs/XMLSchemaLoader.java
diffstat 1 files changed, 13 insertions(+), 3 deletions(-) [+]
line wrap: on
line diff
--- a/src/com/sun/org/apache/xerces/internal/impl/xs/XMLSchemaLoader.java	Tue Jul 29 15:38:08 2014 +0100
+++ b/src/com/sun/org/apache/xerces/internal/impl/xs/XMLSchemaLoader.java	Tue Jul 22 22:06:30 2014 +0400
@@ -54,6 +54,7 @@
 import com.sun.org.apache.xerces.internal.util.SymbolTable;
 import com.sun.org.apache.xerces.internal.util.XMLSymbols;
 import com.sun.org.apache.xerces.internal.utils.SecuritySupport;
+import com.sun.org.apache.xerces.internal.utils.XMLSecurityManager;
 import com.sun.org.apache.xerces.internal.utils.XMLSecurityPropertyManager;
 import com.sun.org.apache.xerces.internal.xni.XNIException;
 import com.sun.org.apache.xerces.internal.xni.grammars.Grammar;
@@ -983,6 +984,18 @@
      */
     public void reset(XMLComponentManager componentManager) throws XMLConfigurationException {
 
+        XMLSecurityPropertyManager spm = (XMLSecurityPropertyManager)componentManager.getProperty(XML_SECURITY_PROPERTY_MANAGER);
+        if (spm == null) {
+            spm = new XMLSecurityPropertyManager();
+            setProperty(XML_SECURITY_PROPERTY_MANAGER, spm);
+        }
+
+        XMLSecurityManager sm = (XMLSecurityManager)componentManager.getProperty(SECURITY_MANAGER);
+        if (sm == null)
+            setProperty(SECURITY_MANAGER,new XMLSecurityManager(true));
+
+        faccessExternalSchema = spm.getValue(XMLSecurityPropertyManager.Property.ACCESS_EXTERNAL_SCHEMA);
+
         fGrammarBucket.reset();
 
         fSubGroupHandler.reset();
@@ -1066,9 +1079,6 @@
         // get generate-synthetic-annotations feature
         fSchemaHandler.setGenerateSyntheticAnnotations(componentManager.getFeature(GENERATE_SYNTHETIC_ANNOTATIONS, false));
         fSchemaHandler.reset(componentManager);
-
-        XMLSecurityPropertyManager spm = (XMLSecurityPropertyManager)componentManager.getProperty(XML_SECURITY_PROPERTY_MANAGER);
-        faccessExternalSchema = spm.getValue(XMLSecurityPropertyManager.Property.ACCESS_EXTERNAL_SCHEMA);
     }
 
     private void initGrammarBucket(){