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); }Activity
Werner Guttmann
made changes -
| Field | Original Value | New Value |
|---|---|---|
| Assignee | Werner Guttmann [ wguttmn ] |
Werner Guttmann
made changes -
| Attachment | patch.c1850.20070221.txt [ 25850 ] |
Werner Guttmann
made changes -
| Fix Version/s | 1.1.2 [ 13440 ] |
Werner Guttmann
made changes -
| Resolution | Fixed [ 1 ] | |
| Status | Open [ 1 ] | Resolved [ 5 ] |
Ralf Joachim
made changes -
| Status | Resolved [ 5 ] | Closed [ 6 ] |
Whilst your patch looks reasonable in what it tries to achieve, the following stack trace shows that the generated output is a bit too 'wordy'.