Uploaded image for project: 'Log4j 2'
  1. Log4j 2
  2. LOG4J2-216

Detach ThrowableProxy from Throwable



    • Wish
    • Status: Resolved
    • Major
    • Resolution: Fixed
    • 2.0-beta4
    • 2.0-beta9
    • None


      org.apache.logging.log4j.core.impl.ThrowableProxy currently has some downsides:

      1.) Due to suppressed, that was added in 1.7, it is only possible to receive/handle exceptions containing suppressed exceptions with 1.7 on both sender and receiver side. A ThrowableProxy data type that does not extend Throwable could simply implement support for suppressed exceptions regardless of the Java version in use.

      2.) It is currently impossible to retrieve the original class name of the Throwable that was the source of a proxy instance. The data exists in ThrowableProxy (the private name attribute) but there is no way to access it.

      3.) There is no way to retrieve commonElementCount.

      4.) Since ThrowableProxy extends Throwable, getCause and the conditionally available getSuppressed will return Throwable instances instead of ThrowableProxy instances - even though the returned instances will always be of type ThrowableProxy. So even if getName() and getCommonElementCount() would get added, a defensive cast would be necessary to access the data.


      Please consider implementing a simple data type without any dependencies introduced by extends.
      See https://github.com/huxi/lilith/blob/master/lilith-data/logging/src/main/java/de/huxhorn/lilith/data/logging/ThrowableInfo.java for an example.

      This data type should include the following methods:

      • String getName() // the FQCN of the original Throwable class
      • ThrowableProxy getCause()
      • ThrowableProxy[] getSuppressed()
      • int getOmittedElements() (or something similar, commonElementCount)

      Put that data type into org.apache.logging.log4j.core instead of org.apache.logging.log4j.core.impl (making it part of the public API) and change org.apache.logging.log4j.core.LogEvent.getThrown() to return a ThrowableProxy instead of Throwable.


        Issue Links



              Unassigned Unassigned
              huxi Joern Huxhorn
              1 Vote for this issue
              3 Start watching this issue