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

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

XMLWordPrintable

    • Icon: Enhancement Enhancement
    • Resolution: Not an Issue
    • Icon: P3 P3
    • None
    • 9
    • 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.

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

              Created:
              Updated:
              Resolved: