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

Validator.set/getProperty() throws SAXNotRecognizedException instead of NPE

XMLWordPrintable

    • 1.3
    • generic
    • generic

        Name: eaR10174 Date: 12/17/2003


        The methods

             javax.xml.validation.Validator.getProperty()
             javax.xml.validation.Validator.setProperty()

        throw SAXNotRecognizedException instead of NullPointerException in case when a property 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/Validator/index.html#GetSetProperty[GetSetProperty001]
            api/javax_xml/validation/Validator/index.html#GetSetProperty[GetSetProperty003]

        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;
        import javax.xml.validation.Validator;

        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 {
                     Validator validator = schemaFactory.newSchema().newValidator();
                     System.out.println("Validator.getProperty(null)");
                     validator.getProperty(null);
                 } catch (Exception e) {
                     if (e instanceof NullPointerException) {
                         System.out.println("OK");
                     } else {
                         System.out.print("Failed. ");
                         e.printStackTrace();
                     }
                 }
              }

              public void run02() {
                 try {
                     Validator validator = schemaFactory.newSchema().newValidator();
                     System.out.println("Validator.setProperty(null, \"123\")");
                     validator.setProperty(null, "123");
                 } 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)

        Validator.getProperty(null)
        Failed. org.xml.sax.SAXNotRecognizedException
        at javax.xml.validation.Validator.getProperty(Validator.java:395)
        at test.run01(test.java:19)
        at test.main(test.java:9)


        Validator.setProperty(null, "123")
        Failed. org.xml.sax.SAXNotRecognizedException
        at javax.xml.validation.Validator.setProperty(Validator.java:365)
        at test.run02(test.java:34)
        at test.main(test.java:12)
        --------------------------------------------------------------------------

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

              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: