Log4j 2
  1. Log4j 2
  2. LOG4J2-299

Ability to retrieve original Throwable from ThrowableProxy

    Details

    • Type: Improvement Improvement
    • Status: Closed
    • Priority: Major Major
    • Resolution: Fixed
    • Affects Version/s: 2.0-beta7
    • Fix Version/s: 2.0-beta9
    • Component/s: Core
    • Labels:
      None

      Description

      If ThrowableProxy is to exist without change, it would be polite to provide mechanism to retrieve the initial source Throwable in an unadulterated form.

      As already reported it's impossible to retrieve the original class name of the Throwable that was the source of a proxy instance, though the data exists as the private name attribute, which wouldn't be an issue at all if we could merely access the

      Say via something like:
      public Throwable proxiedThrown()

        Issue Links

          Activity

          Hide
          jeremy franklin-ross added a comment -

          verified, thanks

          Show
          jeremy franklin-ross added a comment - verified, thanks
          Hide
          Ralph Goers added a comment -

          getThrowable was added in revision 1504373. Please verify and close.

          Show
          Ralph Goers added a comment - getThrowable was added in revision 1504373. Please verify and close.
          Hide
          Ralph Goers added a comment -

          There are a couple of issues related to ThrowableProxy. I plan to address them very soon.

          Show
          Ralph Goers added a comment - There are a couple of issues related to ThrowableProxy. I plan to address them very soon.
          Hide
          Gary Gregory added a comment -

          Hm... I now see that there is a get API that returns a ThrowableProxy[]. We could save the original exception and add a getter...

          Ralph?

          Show
          Gary Gregory added a comment - Hm... I now see that there is a get API that returns a ThrowableProxy[]. We could save the original exception and add a getter... Ralph?
          Hide
          jeremy franklin-ross added a comment -

          Gary, That doesn't read true... It appears that we set our suppressed Throwable to a new ThrowableProxy, rather than the original throwable. Perhaps this is a bug? Line 528 below.

          523 private void setSuppressed(final Throwable throwable) {
          524 if (getSuppressed != null && addSuppressed != null) {
          525 try {
          526 final Throwable[] array = (Throwable[]) getSuppressed.invoke(throwable);
          527 for (final Throwable t : array)

          { 528 addSuppressed.invoke(this, new ThrowableProxy(t)); 529 }

          530 } catch (final Exception ignore)

          { 531 // 532 }

          533 }
          534 }

          Show
          jeremy franklin-ross added a comment - Gary, That doesn't read true... It appears that we set our suppressed Throwable to a new ThrowableProxy, rather than the original throwable. Perhaps this is a bug? Line 528 below. 523 private void setSuppressed(final Throwable throwable) { 524 if (getSuppressed != null && addSuppressed != null) { 525 try { 526 final Throwable[] array = (Throwable[]) getSuppressed.invoke(throwable); 527 for (final Throwable t : array) { 528 addSuppressed.invoke(this, new ThrowableProxy(t)); 529 } 530 } catch (final Exception ignore) { 531 // 532 } 533 } 534 }
          Hide
          Gary Gregory added a comment -

          If you are on Java 7, you can call Throwable#getSuppressed()

          Show
          Gary Gregory added a comment - If you are on Java 7, you can call Throwable#getSuppressed()

            People

            • Assignee:
              Unassigned
              Reporter:
              jeremy franklin-ross
            • Votes:
              0 Vote for this issue
              Watchers:
              3 Start watching this issue

              Dates

              • Created:
                Updated:
                Resolved:

                Time Tracking

                Estimated:
                Original Estimate - 24h
                24h
                Remaining:
                Remaining Estimate - 24h
                24h
                Logged:
                Time Spent - Not Specified
                Not Specified

                  Development