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>

          Issue Links

            Activity

            Hide
            hgupdate HG Updates added a comment -
            URL: http://hg.openjdk.java.net/jdk9/dev/jaxp/rev/95c223e6eaf0
            User: joehw
            Date: 2016-02-22 19:00:14 +0000
            Show
            hgupdate HG Updates added a comment - URL: http://hg.openjdk.java.net/jdk9/dev/jaxp/rev/95c223e6eaf0 User: joehw Date: 2016-02-22 19:00:14 +0000
            Hide
            hgupdate HG Updates added a comment -
            URL: http://hg.openjdk.java.net/jdk9/jdk9/jaxp/rev/95c223e6eaf0
            User: lana
            Date: 2016-03-02 19:34:31 +0000
            Show
            hgupdate HG Updates added a comment - URL: http://hg.openjdk.java.net/jdk9/jdk9/jaxp/rev/95c223e6eaf0 User: lana Date: 2016-03-02 19:34:31 +0000

              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: