Author: swapnilmmane
Date: Wed Mar 20 12:15:59 2019
New Revision: 1855898
URL:
http://svn.apache.org/viewvc?rev=1855898&view=revLog:
Improved: Moved the nodeType check after node.getTextContent() method call
(OFBIZ-10832)
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.
Modified:
ofbiz/ofbiz-framework/trunk/framework/base/src/main/java/org/apache/ofbiz/base/util/ObjectType.java
Modified: ofbiz/ofbiz-framework/trunk/framework/base/src/main/java/org/apache/ofbiz/base/util/ObjectType.java
URL:
http://svn.apache.org/viewvc/ofbiz/ofbiz-framework/trunk/framework/base/src/main/java/org/apache/ofbiz/base/util/ObjectType.java?rev=1855898&r1=1855897&r2=1855898&view=diff==============================================================================
--- ofbiz/ofbiz-framework/trunk/framework/base/src/main/java/org/apache/ofbiz/base/util/ObjectType.java (original)
+++ ofbiz/ofbiz-framework/trunk/framework/base/src/main/java/org/apache/ofbiz/base/util/ObjectType.java Wed Mar 20 12:15:59 2019
@@ -290,17 +290,20 @@ public class ObjectType {
if (obj instanceof Node) {
Node node = (Node) obj;
- /* 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
- *
https://docs.oracle.com/javase/7/docs/api/org/w3c/dom/Node.html#getTextContent() for more details.
- */
- short nodeType = node.getNodeType();
- if (Node.DOCUMENT_NODE == nodeType || Node.DOCUMENT_TYPE_NODE == nodeType || Node.NOTATION_NODE == nodeType) {
- return 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
+ *
https://docs.oracle.com/javase/7/docs/api/org/w3c/dom/Node.html#getTextContent() for more details.
+ */
+ short nodeType = node.getNodeType();
+ if (Node.DOCUMENT_NODE == nodeType || Node.DOCUMENT_TYPE_NODE == nodeType || Node.NOTATION_NODE == nodeType) {
+ return obj;
+ }
+ }
if ("String".equals(type) || "java.lang.String".equals(type)) {
return nodeValue;
}