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

ValidatorHandler.getFeature() throws SAXNotRecognizedException instead of NPE

XMLWordPrintable

    • b36
    • generic
    • generic
    • Verified

      Name: eaR10174 Date: 12/22/2003


      The method

           javax.xml.validation.ValidatorHandler.getFeature()

      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[GetSetFeature001]

      The following test fails running on JDK 1.5.0-beta-b32.
      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 {
                   System.out.println("ValidatorHandler.getFeature(null)");
                   ValidatorHandler validatorHandler = schemaFactory.newSchema().newValidatorHandler();
                   validatorHandler.getFeature(null);
               } 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-b32)
      Java HotSpot(TM) Client VM (build 1.5.0-beta-b32, mixed mode)

      ValidatorHandler.getFeature(null)
      Failed. org.xml.sax.SAXNotRecognizedException
      at javax.xml.validation.ValidatorHandler.getFeature(ValidatorHandler.java:349)
      at test.run(test.java:17)
      at test.main(test.java:10)
      --------------------------------------------------------------------------

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

            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: