-
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
Change AssumptionViolatedException to not set the cause to null; fixes issue #494 #985
Change AssumptionViolatedException to not set the cause to null; fixes issue #494 #985
Conversation
I think we should ask @mmichaelis who reported #494 to take a look and make sure we solve his problem, shouldn't we? |
Thanks for referring to me... and actually thanks for fixing! Yes, I think the suggested solution works as it does not overwrite "this" cause in Throwable by accident. The only thing to add: I think a test-case is missing which would show the failure in the previous version. Suggested test: @Test
public void causeCanBeInitializedLater() {
Throwable cause = new Exception();
AssumptionViolatedException e = new AssumptionViolatedException("invalid number");
// Old behavior: Following statement would raise IllegalStateException: "Can't overwrite cause"
// triggered by Throwable#initCause().
e.initCause(cause);
assertThat(e.getCause(), is(cause));
} |
@mmichaelis I would think your proposed test would be covered by the tests that @marcin-lawrowski wrote that checked for a |
@kcooney No, that's not enough as you cannot distinguish via
public Throwable getCause() {
return (cause==this ? null : cause);
} |
6f9e4c0
to
daa46e4
Compare
@mmichaelis got it. Updated one of the tests we added to call |
@kcooney Great. Thanks a lot! |
Change AssumptionViolatedException to not set the cause to null; fixes issue #494
@kcooney We should mention this fix in the release notes. I have already moved them from the wiki into the repository. Do you have time to do it? |
@marcphilipp Filed #987 to update the release notes. |
Great, thanks! |
No description provided.