-
Bug
-
Resolution: Fixed
-
P4
-
5.0
-
1.3
-
x86
-
linux
-
Verified
Issue | Fix Version | Assignee | Priority | Status | Resolution | Resolved In Build |
---|---|---|---|---|---|---|
JDK-2178857 | 7 | Unassigned | P3 | Closed | Not an Issue | |
JDK-2178858 | 6-pool | Abhijit Saha | P3 | Closed | Not an Issue | |
JDK-2179184 | 5.0u23 | Abhijit Saha | P3 | Resolved | Fixed | b01 |
Run the following on JDK 5:
---%<---
import javax.xml.parsers.DocumentBuilderFactory;
import org.w3c.dom.Document;
import org.w3c.dom.Element;
import org.w3c.dom.ls.DOMImplementationLS;
public class TestDOMSerializerImpl {
public static void main(String[] args) throws Exception {
Document doc = DocumentBuilderFactory.newInstance().newDocumentBuilder().newDocument();
Element el = doc.createElement("x");
DOMImplementationLS ls = (DOMImplementationLS) doc.getImplementation().getFeature("LS", "3.0");
System.out.println(ls.createLSSerializer().writeToString(el));
}
}
---%<---
I get:
---%<---
java version "1.5.0_15"
Java(TM) 2 Runtime Environment, Standard Edition (build 1.5.0_15-b04)
Java HotSpot(TM) Server VM (build 1.5.0_15-b04, mixed mode)
Exception in thread "main" org.w3c.dom.ls.LSException: java.lang.NullPointerException
at com.sun.org.apache.xml.internal.serialize.DOMSerializerImpl.writeToString(DOMSerializerImpl.java:546)
at TestDOMSerializerImpl.main(TestDOMSerializerImpl.java:10)
---%<---
The lack of a proper stack trace is recorded in bug #6710741, but using a source debugger shows that the culprit is prepareForSerialization:
next = node.getNextSibling();
The bug appears to be fixed in JDK 6; perhaps the fix can be backported?
---%<---
import javax.xml.parsers.DocumentBuilderFactory;
import org.w3c.dom.Document;
import org.w3c.dom.Element;
import org.w3c.dom.ls.DOMImplementationLS;
public class TestDOMSerializerImpl {
public static void main(String[] args) throws Exception {
Document doc = DocumentBuilderFactory.newInstance().newDocumentBuilder().newDocument();
Element el = doc.createElement("x");
DOMImplementationLS ls = (DOMImplementationLS) doc.getImplementation().getFeature("LS", "3.0");
System.out.println(ls.createLSSerializer().writeToString(el));
}
}
---%<---
I get:
---%<---
java version "1.5.0_15"
Java(TM) 2 Runtime Environment, Standard Edition (build 1.5.0_15-b04)
Java HotSpot(TM) Server VM (build 1.5.0_15-b04, mixed mode)
Exception in thread "main" org.w3c.dom.ls.LSException: java.lang.NullPointerException
at com.sun.org.apache.xml.internal.serialize.DOMSerializerImpl.writeToString(DOMSerializerImpl.java:546)
at TestDOMSerializerImpl.main(TestDOMSerializerImpl.java:10)
---%<---
The lack of a proper stack trace is recorded in bug #6710741, but using a source debugger shows that the culprit is prepareForSerialization:
next = node.getNextSibling();
The bug appears to be fixed in JDK 6; perhaps the fix can be backported?
- backported by
-
JDK-2179184 DOMSerializerImpl.prepareForSerialization throws NPE
- Resolved
-
JDK-2178857 DOMSerializerImpl.prepareForSerialization throws NPE
- Closed
-
JDK-2178858 DOMSerializerImpl.prepareForSerialization throws NPE
- Closed
- relates to
-
JDK-2179013 DOMSerializerImpl.writeToString swallows nested exceptions
- Closed