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

    Details

    • Type: Enhancement
    • Status: Closed
    • Priority: P3
    • Resolution: Not an Issue
    • Affects Version/s: 9
    • Fix Version/s: None
    • Component/s: xml
    • Labels:
      None
    • Introduced In Version:
      5.0

      Description

      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.

        Attachments

          Issue Links

            Activity

              People

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

                Dates

                • Created:
                  Updated:
                  Resolved: