Details
-
Wish
-
Status: Resolved
-
Major
-
Resolution: Fixed
-
2.8.5
-
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; }