REASSERT Code review request for 8012044: Give more information about self-suppression from Throwable.addSuppressed (original) (raw)

Jason Mehrens jason_mehrens at hotmail.com
Thu Apr 25 15:50:18 UTC 2013


Looks good. I still think last sentence of the Throwable.addSuppressed javadocs side steps the counter arguments.

Thanks for working on this,

Jason


Date: Thu, 25 Apr 2013 00:16:05 -0700 From: joe.darcy at oracle.com To: david.holmes at oracle.com; Alan.Bateman at oracle.com Subject: Re: REASSERT Code review request for 8012044: Give more information about self-suppression from Throwable.addSuppressed CC: core-libs-dev at openjdk.java.net

Hello, Responding to David's comment and some comments from Alan off-list, here is a variant which doesn't use suppressed exceptions in initCause, but still passes along some information: http://cr.openjdk.java.net/~darcy/8012044.4 Patch to Throwable: --- a/src/share/classes/java/lang/Throwable.java Wed Apr 24 21:27:52 2013 +0000 +++ b/src/share/classes/java/lang/Throwable.java Thu Apr 25 00:15:32 2013 -0700 @@ -453,9 +453,10 @@ */ public synchronized Throwable initCause(Throwable cause) { if (this.cause != this) - throw new IllegalStateException("Can't overwrite cause"); + throw new IllegalStateException("Can't overwrite cause with " + + Objects.toString(cause, "a null"), this); if (cause == this) - throw new IllegalArgumentException("Self-causation not permitted"); + throw new IllegalArgumentException("Self-causation not permitted", this); this.cause = cause; return this; } @@ -1039,7 +1040,7 @@ */ public final synchronized void addSuppressed(Throwable exception) { if (exception == this) - throw new IllegalArgumentException(SELFSUPPRESSIONMESSAGE); + throw new IllegalArgumentException(SELFSUPPRESSIONMESSAGE, exception); if (exception == null) throw new NullPointerException(NULLCAUSEMESSAGE); Thanks, -Joe



More information about the core-libs-dev mailing list