From f01e4cf67c4c82dac5975bf638020006c5788ea0 Mon Sep 17 00:00:00 2001 From: Swapnil Mane Date: Wed, 13 Mar 2019 12:34:45 +0000 Subject: [PATCH] Applied fix from trunk for revision: 1855403 === 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. git-svn-id: https://svn.apache.org/repos/asf/ofbiz/ofbiz-framework/branches/release18.12@1855408 13f79535-47bb-0310-9956-ffa450edef68 --- .../java/org/apache/ofbiz/base/util/ObjectType.java | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/framework/base/src/main/java/org/apache/ofbiz/base/util/ObjectType.java b/framework/base/src/main/java/org/apache/ofbiz/base/util/ObjectType.java index 04300e808b..26715c7ee4 100644 --- a/framework/base/src/main/java/org/apache/ofbiz/base/util/ObjectType.java +++ b/framework/base/src/main/java/org/apache/ofbiz/base/util/ObjectType.java @@ -515,6 +515,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;