castor
  1. castor
  2. CASTOR-1850

XMLException returns null when toString is called

    Details

    • Type: Bug Bug
    • Status: Closed Closed
    • Priority: Major Major
    • Resolution: Fixed
    • Affects Version/s: 1.0.5
    • Fix Version/s: 1.1.2
    • Component/s: XML
    • Labels:
      None
    • Testcase included:
      yes
    • Number of attachments :
      2

      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); }
      1. ex-tostring-patch.txt
        1 kB
        Paul Philion
      2. patch.c1850.20070221.txt
        6 kB
        Werner Guttmann

        Activity

          People

          • Assignee:
            Werner Guttmann
            Reporter:
            Paul Philion
          • Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

            Dates

            • Created:
              Updated:
              Resolved: