United StatesChange Country, Oracle Worldwide Web Sites Communities I am a... I want to...
Bug ID: JDK-6710741 DOMSerializerImpl.writeToString swallows nested exceptions
JDK-6710741 : DOMSerializerImpl.writeToString swallows nested exceptions

Details
Type:
Bug
Submit Date:
2008-06-04
Status:
Closed
Updated Date:
2012-04-25
Project Name:
JDK
Resolved Date:
2009-06-18
Component:
xml
OS:
linux
Sub-Component:
org.w3c.dom
CPU:
x86
Priority:
P4
Resolution:
Fixed
Affected Versions:
5.0
Fixed Versions:
1.3.0 (1.3)

Related Reports
Backport:
Backport:
Backport:

Sub Tasks

Description
com.sun.org.apache.xml.internal.serialize.DOMSerializerImpl.writeToString(Node) has code like this:

try {
  // ...
} catch (RuntimeException e) {
  // ...
  throw new LSException(LSException.SERIALIZE_ERR, e.toString());
} catch (IOException ioe) {
  // ...
  throw new DOMException(DOMException.DOMSTRING_SIZE_ERR, msg);
}

If there is a failure from some implementation-internal code, the stack trace will be lost.

Observed because prepareForSerialization can throw NPE in

  next = node.getNextSibling();

which I will report separately if I can figure out under which conditions it occurs.

Observed in JDK 5 but JDK 7 seems to still have the same code.

                                    

Comments
SUGGESTED FIX

Always use Throwable.initCause() when rethrowing an exception as a different type.
                                     
2008-06-04
EVALUATION

Several exception classes in the JAXP API swallow cause in the same way as indicated in this report. Because it involves API changes, we should consider this in future release, e.g. jaxp 1.5.
                                     
2009-06-16
EVALUATION

We've decided to fix this specific case since it affected NetBeans development. For all other cases, I've created a new request. See 6852393.

This is now fixed in jaxp 1.3, 1.4. Integrations into jdk5/6/7 will follow.
                                     
2009-06-18



Hardware and Software, Engineered to Work Together