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

XPath.setXXX() methods do not throw NullPointerException

    Details

    • Subcomponent:
    • Resolved In Build:
      1.3
    • CPU:
      generic
    • OS:
      generic

      Backports

        Description



        Name: eaR10174 Date: 10/27/2003


          The following methods of the class javax.xml.xpath.XPath
          
             public void setFunctionResolver(XPathFunctionResolver resolver)
             public void setNamespaceContext(NamespaceContext nsContext)
             public void setVariableResolver(XPathVariableResolver resolver)

        do not throw NullPointerException in case when null is passed to them (see test.java
        below). According to the javadoc

           public void setFunctionResolver(XPathFunctionResolver resolver)
              ...
              A NullPointerException is trown if resolver is null.
            
           public void setNamespaceContext(NamespaceContext nsContext)
              ...
              A NullPointerException is trown if resolver is null
          
           public void setVariableResolver(XPathVariableResolver resolver)
              ...
              A NullPointerException is trown if resolver is null.


        the methods should throw NullPointerException in such a case.

          The bug appears in jdk1.5.0beta-b25 and affects new JCK1.5 tests:
          
            api/javax_xml/xpath/XPath/index.html#SetGet[SetGet003]
            api/javax_xml/xpath/XPath/index.html#SetGet[SetGet006]
            api/javax_xml/xpath/XPath/index.html#SetGet[SetGet009]

        ------------------------------------test.java-----------------------------
        import javax.xml.xpath.XPath;
        import javax.xml.xpath.XPathFactory;

        public class test {

            public static void main (String[] args) {
                try {
                    XPathFactory xpf = XPathFactory.newInstance();
                    XPath xpath = xpf.newXPath();
                    
                    try {
                        xpath.setFunctionResolver(null);
                        System.out.println("setFunctionResolver: NPE not thrown.");
                    } catch (NullPointerException e) {
                        System.out.println("setFunctionResolver: OK");
                    }
                    
                    try {
                        xpath.setNamespaceContext(null);
                        System.out.println("setNamespaceContext: NPE not thrown.");
                    } catch (NullPointerException e) {
                        System.out.println("setNamespaceContext: OK");
                    }

                    try {
                        xpath.setVariableResolver(null);
                        System.out.println("setVariableResolver: NPE not thrown.");
                    } catch (NullPointerException e) {
                        System.out.println("setVariableResolver: OK");
                    }
                } catch (Exception e) {
                    e.printStackTrace();
                }
            }
        }
        --------------------------------------------------------------------------
        % java -showversion test
        Java(TM) 2 Runtime Environment, Standard Edition (build 1.5.0-beta-b25)
        Java HotSpot(TM) Client VM (build 1.5.0-beta-b25, mixed mode)

        setFunctionResolver: NPE not thrown.
        setNamespaceContext: NPE not thrown.
        setVariableResolver: NPE not thrown.
        --------------------------------------------------------------------------


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

          Attachments

            Issue Links

              Activity

                People

                • Assignee:
                  rmandavasunw Ramesh Mandava (Inactive)
                  Reporter:
                  evgsunw Evg Evg (Inactive)
                • Votes:
                  0 Vote for this issue
                  Watchers:
                  0 Start watching this issue

                  Dates

                  • Created:
                    Updated:
                    Resolved:
                    Imported:
                    Indexed: