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

SchemaFactory.set/getFeature() throws SAXNotRecognizedException instead of NPE

XMLWordPrintable

    • 1.3
    • generic
    • generic

        Name: eaR10174 Date: 12/17/2003


        The methods

             javax.xml.validation.SchemaFactory.getFeature()
             javax.xml.validation.SchemaFactory.setFeature()

        throw SAXNotRecognizedException instead of NullPointerException in case when a feature name is
        null. The methods should throw NullPointerException according to the javadoc.

        The bug affects new JCK1.5 tests (not integrated yet):

            api/javax_xml/validation/SchemaFactory/index.html#GetSetFeature[GetSetFeature001]
            api/javax_xml/validation/SchemaFactory/index.html#GetSetFeature[GetSetFeature003]

        The following test fails running on JDK 1.5.0-beta-b31.
        See below the test source and the execution log:
        ------------------------------------test.java-----------------------------
        import javax.xml.validation.SchemaFactory;

        public class test {
              SchemaFactory schemaFactory =
                  SchemaFactory.newInstance("http://www.w3.org/2001/XMLSchema");

              public static void main(String argv[]) {
                  test t = new test();
                  t.run01();
                  System.out.println("\n");

                  t.run02();
              }

              public void run01() {
                 try {
                     System.out.println("SchemaFactory.getFeature(null)");
                     schemaFactory.getFeature(null);
                 } catch (Exception e) {
                     if (e instanceof NullPointerException) {
                         System.out.println("OK");
                     } else {
                         System.out.print("Failed. ");
                         e.printStackTrace();
                     }
                 }
              }

              public void run02() {
                 try {
                     System.out.println("SchemaFactory.setFeature(null, false)");
                     schemaFactory.setFeature(null, false);
                 } catch (Exception e) {
                     if (e instanceof NullPointerException) {
                         System.out.println("OK");
                     } else {
                         System.out.print("Failed. ");
                         e.printStackTrace();
                     }
                 }
              }
        }
        --------------------------------------------------------------------------
        % java -showversion test
        java version "1.5.0-beta"
        Java(TM) 2 Runtime Environment, Standard Edition (build 1.5.0-beta-b31)
        Java HotSpot(TM) Client VM (build 1.5.0-beta-b31, mixed mode)

        SchemaFactory.getFeature(null)
        Failed. org.xml.sax.SAXNotRecognizedException
        at javax.xml.validation.SchemaFactory.getFeature(SchemaFactory.java:178)
        at test.run01(test.java:17)
        at test.main(test.java:8)


        SchemaFactory.setFeature(null, false)
        Failed. org.xml.sax.SAXNotRecognizedException
        at javax.xml.validation.SchemaFactory.setFeature(SchemaFactory.java:207)
        at test.run02(test.java:31)
        at test.main(test.java:11)
        --------------------------------------------------------------------------

        ======================================================================

              kkawagucsunw Kohsuke Kawaguchi (Inactive)
              evgsunw Evg Evg (Inactive)
              Votes:
              0 Vote for this issue
              Watchers:
              0 Start watching this issue

                Created:
                Updated:
                Resolved:
                Imported:
                Indexed: