-
Notifications
You must be signed in to change notification settings - Fork 3.3k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
AssumptionViolatedException erroneously initializes cause to "null" #494
Comments
This workaround works for me for now: throw new AssumptionViolatedException(message) {
@Override
public Throwable getCause() {
return lastException;
}
}; |
Is this still an open issue? How can I help? |
It looks like it is still open, and should be an easy and safe enough fix to squeeze into 4.12. |
So, the first constructor in org.junit.internal.AssumptionViolatedException class should be fixed to initialize superclass with "this" instead of "null" ? |
I believe the first constructor should init the cause via |
Change AssumptionViolatedException to not set the cause to null; fixes issue #494
Fixed by #985. |
Digging into the code of AssumptionViolatedException you will find:
According the documentation of "cause" in
java.lang.Throwable
this states that there is no (known) cause for this exception. If instead the cause is not yet initialized the cause should point tothis
- which is the initial value in Throwable.For the work I am doing I need to specify a message and a cause. Having the current API this is not possible:
initCause()
cannot be called because Throwable does not allow to set the cause twice (and it got set to null before)For me the solution would be sufficient to introduce a constructor
AssumptionViolatedException(message, cause)
. But the real problem (from my point of view) is the erroneous initialization withnull
.The text was updated successfully, but these errors were encountered: