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

Bug 13586966 - NPE IN PARSERCONFIGURATIONSETTINGS.ADDRECOGNIZEDFEATURES

    XMLWordPrintable

Details

    • Bug
    • Resolution: Fixed
    • P2
    • 7u4
    • 7
    • xml
    • b11
    • generic
    • generic
    • Not verified

    Description

      @ In WLS, we discovered an issue when using a SchemaFactory from a different
      @ version of xerces than bundled with the JDK. See bug 12962723 for details.
      @ Synopsis is as follows:
      @ .
      @ In Java 6, there is an NPE check(
      @ public void addRecognizedFeatures(String[] featureIds) {
      @ .
      @ // add recognized features
      @ int featureIdsCount = featureIds != null ? featureIds.length : 0;
      @ for (int i = 0; i < featureIdsCount; i++) {
      @ String featureId = featureIds[i];
      @ if (!fRecognizedFeatures.contains(featureId)) {
      @ fRecognizedFeatures.add(featureId);
      @ }
      @ }
      @ .
      @ }
      @ .
      @ But NPE check disappears in Java7
      @ public void addRecognizedFeatures(String[] featureIds) {
      @ fRecognizedFeatures.addAll(Arrays.asList(featureIds));
      @ } // addRecognizedFeatures(String[])
      @ .
      @ .
      @ This can be easily reproduced with the following test case. Run with JDK7 &
      @ nothing on the classpath, it passes. Run with JDK7 and add xercesImpl.jar to
      @ the classpath & it fails with the error indicated in the bug.
      @ .
      @ import javax.xml.validation.Schema;
      @ import javax.xml.validation.SchemaFactory;
      @ import javax.xml.XMLConstants;
      @ import javax.xml.parsers.SAXParserFactory;
      @ .
      @ public class test {
      @ public static void main(String[] args) throws Exception {
      @ System.setProperty("javax.xml.parsers.SAXParserFactory",
      @
      @ "com.sun.org.apache.xerces.internal.jaxp.SAXParserFactoryImpl");
      @ SAXParserFactory factory = SAXParserFactory.newInstance();
      @ System.out.println(factory.getClass().getName());
      @ Schema schema = SchemaFactory.newInstance(
      @ XMLConstants.W3C_XML_SCHEMA_NS_URI).newSchema();
      @ factory.setSchema(schema);
      @ factory.newSAXParser();
      @ .
      @ }
      @ }
      @ .

      Attachments

        Issue Links

          Activity

            People

              joehw Joe Wang
              joehw Joe Wang
              Votes:
              0 Vote for this issue
              Watchers:
              0 Start watching this issue

              Dates

                Created:
                Updated:
                Resolved:
                Imported:
                Indexed: