-
Notifications
You must be signed in to change notification settings - Fork 25
Open
Description
So your code in TraceurException is
public Throwable appendTo(Throwable throwable) {
Throwable t = throwable;
while (t.getCause() != null) {
t = t.getCause();
// Won't be able to init the cause of this with self
if (t == this) {
return throwable;
}
if (logLevel == LogLevel.SHOW_ONLY_FIRST && t instanceof TraceurException) {
return throwable;
}
}
t.initCause(this);
return throwable;
}
but the code inside Throwable is
public synchronized Throwable initCause(Throwable cause) {
if (this.cause != this)
throw new IllegalStateException("Can't overwrite cause with " +
Objects.toString(cause, "a null"), this);
if (cause == this)
throw new IllegalArgumentException("Self-causation not permitted", this);
this.cause = cause;
return this;
}
This means the appendTo function will cause an exception to be thrown if a Throwable's cause is ever found to be null.
Possible solution
while (t.getCause() != null) should be while (t.getCause() != null && t.getCause() != t) and wrap the t.initCause(this);with a check againstt.getCause()`'s nullability
I'll make a PR later with this
Metadata
Metadata
Assignees
Labels
No labels