JDK-8081392 : getNodeValue should return 'null' value for Element nodes
  • Type: Bug
  • Component: xml
  • Sub-Component: jaxp
  • Affected Version: 7u80,8u40,9
  • Priority: P3
  • Status: Closed
  • Resolution: Fixed
  • OS: generic
  • CPU: generic
  • Submitted: 2015-05-28
  • Updated: 2016-08-24
  • Resolved: 2015-05-29
The Version table provides details related to the release that this issue/RFE will be addressed.

Unresolved : Release in which this issue/RFE will be addressed.
Resolved: Release in which this issue/RFE has been resolved.
Fixed : Release in which this issue/RFE has been fixed. The release containing this fix may be available for download as an Early Access Release or a General Availability Release.

To download the current JDK release, click here.
JDK 6 JDK 7 JDK 8 JDK 9
6u105Fixed 7u91Fixed 8u60Fixed 9 b68Fixed
Related Reports
Relates :  
Relates :  
Description
Node.getNodeValue() should return NULL values for Element node type [1].
8032908 fix changed that behavior incorrectly. The JDK-8032908 fix should be revisited.
getTextContent() calls getNodeValue() which is incorrect:
java.xml/share/classes/com/sun/org/apache/xml/internal/dtm/ref/DTMNodeProxy.java
@@ -2116,7 +2116,7 @@
      */
     @Override
     public String getTextContent() throws DOMException {
-        return getNodeValue();  // overriden in some subclasses
+        return dtm.getStringValue(node).toString();
     }
 
      /**

8032908 fix should be reverted:
java.xml/share/classes/com/sun/org/apache/xml/internal/dtm/ref/sax2dtm/SAX2DTM2.java
--- a/src/java.xml/share/classes/com/sun/org/apache/xml/internal/dtm/ref/sax2dtm/SAX2DTM2.java  Thu May 21 16:21:00 2015 -0700
+++ b/src/java.xml/share/classes/com/sun/org/apache/xml/internal/dtm/ref/sax2dtm/SAX2DTM2.java  Thu May 28 15:36:38 2015 +0300
@@ -3145,11 +3145,7 @@
                                   m_data.elementAt(-dataIndex+1));
       }
     }
-    else if (DTM.ELEMENT_NODE == type)
-    {
-      return getStringValueX(nodeHandle);
-    }
-    else if (DTM.DOCUMENT_FRAGMENT_NODE == type
+    else if (DTM.ELEMENT_NODE == type || DTM.DOCUMENT_FRAGMENT_NODE == type
              || DTM.DOCUMENT_NODE == type)
     {
       return null;

Few tests should be updated to use the proper functions: 8032908 and 8062518

[1] Table in "Interface Node->Definition group NodeType" section: http://www.w3.org/TR/2000/REC-DOM-Level-2-Core-20001113/core.html#ID-1950641247