Uploaded image for project: 'Red Hat Fuse'
  1. Red Hat Fuse
  2. ENTESB-12210

XPath evaluation fails with null body using Saxon-HE-9.8.0-8_1


    • % %
    • +

      After upgrading to Fuse 7.4, the xpath expressions that operate on header when the exchange body is null are failing with nullpointer exception. This seems to be related to a change that was made in Saxon-HE 9.6 and later

      i have checked both saxon version Saxon-HE-9.5.1-3 and Saxon-HE-9.8.0-8_1


      /*@Nullable*/ public Object evaluate(/*@Nullable*/ Object node, /*@NotNull*/ QName qName) throws XPathExpressionException {
              NodeInfo contextNode = this.contextNode;
              if (node != null) {
                  if (node instanceof SingletonItem) {
                      node = ((SingletonItem)node).asItem();
                  if (node instanceof NodeInfo) {
                      if (!((NodeInfo)node).getConfiguration().isCompatible(config)) {
                          throw new XPathExpressionException(
                                      "Supplied node must be built using the same or a compatible Configuration");

      Saxon-HE-9.8.0-8_1 :

          public Object evaluate(/*@Nullable*/ Object node, /*@NotNull*/ QName qName) throws XPathExpressionException {
              Item contextItem;
              if (node instanceof ZeroOrOne) {
                  node = ((ZeroOrOne) node).head();
              if (node instanceof TreeInfo) {
                  node = ((TreeInfo)node).getRootNode();
              if (node instanceof DocumentInfo) {
                  node = ((DocumentInfo)node).getUnderlyingNode();
              if (node instanceof NodeInfo) {
                  if (!((NodeInfo) node).getConfiguration().isCompatible(config)) 

      Null check on node is removed ' if (node != null) {' removed in latest versions, because of this change throwing NPE if body is Null


      at net.sf.saxon.xpath.XPathExpressionImpl.evaluate(XPathExpressionImpl.java:172)
      at org.apache.camel.builder.xml.XPathBuilder.doInEvaluateAs(XPathBuilder.java:977)
      at org.apache.camel.builder.xml.XPathBuilder.evaluateAs(XPathBuilder.java:850)
      at org.apache.camel.builder.xml.XPathBuilder.matches(XPathBuilder.java:172)

            ldemasi Luigi De Masi
            rhn-support-kkakarla kodandaRamu kakarla
            Francesco Mongiardo Francesco Mongiardo
            0 Vote for this issue
            6 Start watching this issue