Improved: Moved the nodeType check after node.getTextContent() method call
Since most nodes will contain text then it will be more efficient to do a null check after retrieving nodeValue.
Thanks: Scott for your valuable inputs.
@@ -290,6 +290,10 @@ public class ObjectType {
if (obj instanceof Node) {
Node node = (Node) obj;
+
+ String nodeValue = node.getTextContent();
+
+ if (nodeValue == null) {
/* We can't get the text value of Document, Document Type and Notation Node,
* thus simply returning the same object from simpleTypeOrObjectConvert method.
* Please refer to OFBIZ-10832 Jira and
@@ -299,8 +303,7 @@ public class ObjectType {
if (Node.DOCUMENT_NODE == nodeType || Node.DOCUMENT_TYPE_NODE == nodeType || Node.NOTATION_NODE == nodeType) {
return obj;
}
-
- String nodeValue = node.getTextContent();
+ }
if ("String".equals(type) || "java.lang.String".equals(type)) {
return nodeValue;
}
