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

new SchemaFactoryFinder(null) should throw NPE

XMLWordPrintable

    • 1.3
    • generic
    • generic

        new SchemaFactoryFinder(java.lang.ClassLoader loader) should throw NPE when loader is null

        Test Program
        ------------
        import javax.xml.validation.SchemaFactoryFinder;
        import javax.xml.validation.SchemaFactory;

        public class Test1 {

        // constructor
            Test1() {
                  
            }
        // main()
            public static void main(String[] argv) {
                
                Test1 test1 = new Test1();
                test1.checkSchemaFactoryFinder01();

            }

        // test for W3C XML Schema 1.0 - supports
        // Setting the jaxp.debug system property will cause SchemaFactoryFinder to print a lot of debug
        // messages to System.err about what it is doing and where it is looking at.
        // classloader is null , should throw NPE

            private void checkSchemaFactoryFinder01() {
                try {
                    ClassLoader myClassLoader = null;
        SchemaFactoryFinder sff = new SchemaFactoryFinder(myClassLoader);
        System.out.println("Test1/checkSchemaFactoryFinder01() failed , expected NPE not thrown ");
        SchemaFactory sf = sff.newFactory("http://www.w3.org/2001/XMLSchema");
        if( sf instanceof SchemaFactory ){
        System.out.println("Run this as java -Djaxp.debug=1 SchemaFactoryFinder01 to see debug messages");
                    System.out.println("Test1/checkSchemaFactoryFinder01() failed , expected NPE not thrown ");
                    }
        }catch (NullPointerException npe ){
        System.out.println(" NPE thrown in Test1/checkSchemaFactoryFinder01() - passed "+npe.getMessage());
        } catch (Exception e ){
        System.out.println(" Exception thrown in Test1/checkSchemaFactoryFinder01() - failed "+e.getMessage());
        }
            }


        }

              kkawagucsunw Kohsuke Kawaguchi (Inactive)
              saksunw Sreejith Ak (Inactive)
              Votes:
              0 Vote for this issue
              Watchers:
              0 Start watching this issue

                Created:
                Updated:
                Resolved:
                Imported:
                Indexed: