Uploaded image for project: 'Camel'
  1. Camel
  2. CAMEL-5276

Wish ObjectHelper wouldn't return false for a node without children

    XMLWordPrintableJSON

Details

    • Wish
    • Status: Resolved
    • Major
    • Resolution: Fixed
    • 2.8.5
    • 2.8.6, 2.9.3, 2.10.0
    • camel-core
    • Unknown

    Description

      org.apache.camel.util.ObjectHelper's method evaluateValuePredicate(Object) tests to see if an object of type NodeList has any children. If it doesn't have any children it return false?

      What if you have an Element that just has attributes and that is all you need? Would it be possible to check if the object passed in is a Node first and then check to see if it is a list...

      The offending code

          /**
           * Evaluate the value as a predicate which attempts to convert the value to
           * a boolean otherwise true is returned if the value is not null
           */
          public static boolean evaluateValuePredicate(Object value) {
              if (value instanceof Boolean) {
                  return (Boolean)value;
              } else if (value instanceof String) {
                  if ("true".equalsIgnoreCase((String)value)) {
                      return true;
                  } else if ("false".equalsIgnoreCase((String)value)) {
                      return false;
                  }
              } else if (value instanceof NodeList) { //Test for Node here?
                  // is it an empty dom
                  NodeList list = (NodeList) value;
                  return list.getLength() > 0;
              } else if (value instanceof Collection) {
                  // is it an empty collection
                  Collection<?> col = (Collection<?>) value;
                  return col.size() > 0;
              }
              return value != null;
          }
      

      Attachments

        Activity

          People

            njiang Willem Jiang
            bhargett Bobby Hargett
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved: