XPath: inconsistent definition for evaluate methods in XPath and XPathExpression with regard to null value

XMLWordPrintable

    • Type: Enhancement
    • Resolution: Not an Issue
    • Priority: P3
    • None
    • Affects Version/s: 9
    • Component/s: xml
    • None
    • 5.0

      Null handling in XPath and XPathExpression is inconsistent. For the evaluate method that takes source, the definition is:

      NullPointerException - If source or returnType is null.

      For the evaluate method that accepts a context item, the specification states:

      If a null value is provided for item, an empty document will be used for the context.

      The later will result in javax.xml.transform.TransformerException: Unable to evaluate expression using this context, that is confusing to users since the error message is not clear with regard to the nature of the error.


      In JDK-8054196, we've added several evaluateExpression methods in which the definition is clear that NullPointerException should be thrown if any of the parameters is null. I suggest we follow the same rule for the evaluate method.

            Assignee:
            Joe Wang
            Reporter:
            Joe Wang
            Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

              Created:
              Updated:
              Resolved: