svn commit: r1855403 - /ofbiz/ofbiz-framework/trunk/framework/base/src/main/java/org/apache/ofbiz/base/util/ObjectType.java

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
1 message Options
Reply | Threaded
Open this post in threaded view
|

svn commit: r1855403 - /ofbiz/ofbiz-framework/trunk/framework/base/src/main/java/org/apache/ofbiz/base/util/ObjectType.java

Swapnil M Mane
Author: swapnilmmane
Date: Wed Mar 13 12:27:13 2019
New Revision: 1855403

URL: http://svn.apache.org/viewvc?rev=1855403&view=rev
Log:
Fixed: simpleTypeConvert always returns Null for Document, Document Type and Notation Node (OFBIZ-10832)

As per the code, getTextContent() method is used get text content of the node and its descendants but the node.getTextContent() always return Null for the following Node type
DOCUMENT_NODE, DOCUMENT_TYPE_NODE, NOTATION_NODE [1]

Since we can't get the text value of Document, Document Type and Notation Node, thus simply return the same object.

[1] https://docs.oracle.com/javase/7/docs/api/org/w3c/dom/Node.html#getTextContent()

Thanks: Deepak Dixit for reviewing the code.

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=1855403&r1=1855402&r2=1855403&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 13 12:27:13 2019
@@ -289,6 +289,17 @@ 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 ("String".equals(type) || "java.lang.String".equals(type)) {
                 return nodeValue;