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

ValidationHandler.setFeature() throws SAXNotRecognizedException instead of NPE

XMLWordPrintable

    • b36
    • generic
    • generic
    • Verified

        Name: eaR10174 Date: 12/18/2003


        The method

              javax.xml.validation.ValidatorHandler.setFeature()

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

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

             api/javax_xml/validation/ValidatorHandler/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;
        import javax.xml.validation.ValidatorHandler;

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

               public static void main(String argv[]) {
                   test t = new test();
                   t.run();
               }

               public void run() {
                  try {
                      ValidatorHandler validatorHandler =
                          schemaFactory.newSchema().newValidatorHandler();
                      validatorHandler.setFeature(null, false);
                  } catch (Exception e) {
                      if (e instanceof NullPointerException) {
                          System.out.println("OK");
                      } else {
                          System.out.print("Failed. ");
                          e.printStackTrace();
                      }
                  }
               }
        }
        --------------------------------------------------------------------------
        % java -showversion test
        Failed. org.xml.sax.SAXNotRecognizedException
        at javax.xml.validation.ValidatorHandler.setFeature(ValidatorHandler.java:380)
        at test.run(test.java:15)
        at test.main(test.java:9)
        --------------------------------------------------------------------------

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

              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: