Uploaded image for project: 'JDK'
  1. JDK
  2. JDK-8149915

enabling validate-annotations feature for xsd schema with annotation causes NPE

    Details

    • Type: Bug
    • Status: Resolved
    • Priority: P3
    • Resolution: Fixed
    • Affects Version/s: None
    • Fix Version/s: 9
    • Component/s: xml
    • Labels:
      None
    • Subcomponent:
    • Resolved In Build:
      b108

      Backports

        Description

        When an xsd that contains annotations is validated with the feature "http://apache.org/xml/features/validate-annotations" enabled, validation fails throwing a NullPointerException:

        Exception in thread "main" java.lang.NullPointerException at com.sun.org.apache.xerces.internal.impl.XMLEntityManager.reset(XMLEntityManager.java:1525) at com.sun.org.apache.xerces.internal.parsers.XML11Configuration.resetCommon(XML11Configuration.java:1051) at com.sun.org.apache.xerces.internal.parsers.XML11Configuration.parse(XML11Configuration.java:838) at com.sun.org.apache.xerces.internal.parsers.XML11Configuration.parse(XML11Configuration.java:805) at com.sun.org.apache.xerces.internal.impl.xs.traversers.XSDHandler.validateAnnotations(XSDHandler.java:685) at com.sun.org.apache.xerces.internal.impl.xs.traversers.XSDHandler.parseSchema(XSDHandler.java:665) at com.sun.org.apache.xerces.internal.impl.xs.XMLSchemaLoader.loadSchema(XMLSchemaLoader.java:612) at com.sun.org.apache.xerces.internal.impl.xs.XMLSchemaLoader.loadGrammar(XMLSchemaLoader.java:571) at com.sun.org.apache.xerces.internal.impl.xs.XMLSchemaLoader.loadGrammar(XMLSchemaLoader.java:537) at com.sun.org.apache.xerces.internal.jaxp.validation.XMLSchemaFactory.newSchema(XMLSchemaFactory.java:266) at javax.xml.validation.SchemaFactory.newSchema(SchemaFactory.java:649)

        Following code snippet to reproduce:
        SchemaFactory factory = SchemaFactory.newInstance(XMLConstants.W3C_XML_SCHEMA_NS_URI);
        // "http://apache.org/xml/features/validate-annotations"
        factory.setFeature(Constants.XERCES_FEATURE_PREFIX + Constants.VALIDATE_ANNOTATIONS_FEATURE, true); factory.newSchema(new File(XSDValidator.class.getResource("testxsd.xsd").getFile()));

        This is the xsd content:
        <?xml version="1.0" encoding="UTF-8"?>
        <xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema">
        <xs:annotation>
           <xs:appinfo>Testapp for XSD annotation issue</xs:appinfo>
           <xs:documentation xml:lang="en">This is an XSD annotation, just for the sake of it.</xs:documentation>
        </xs:annotation>
        </xs:schema>

          Attachments

            Issue Links

              Activity

                People

                • Assignee:
                  clanger Christoph Langer
                  Reporter:
                  clanger Christoph Langer
                • Votes:
                  0 Vote for this issue
                  Watchers:
                  3 Start watching this issue

                  Dates

                  • Created:
                    Updated:
                    Resolved: