Details
Description
If an XMLException (or subclass, like MarshalException) is created to wrap a causing exception with no message (a NullPointerException, in my case), then toString() on the XMLException will result in a null.
This, in turn, causes problems in log4j, when it is generating a stack trace (see org.apache.log4j.spi.ThrowableInformation.getThrowableStrRep, which generates a stack trace vector will nulls in it). This, in turn, breaks error logging in weird and wonderful ways.
I have patched the toString() method of XMLException to be more consistent with the toString() method in java.lang.Throwable.
The testcase is simple:
public void testWrappedExceptionToString()
{ Exception ex = new NullPointerException(); // note: no message MarshalException me = new MarshalException(ex); String strVal = me.toString(); assertNotNull("MarshalException toString is null", strVal); }