Skip to content
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

AssertionFailedError: Enable Java-behavior for late cause initialisation #19

Closed
wants to merge 1 commit into from

Conversation

mmichaelis
Copy link
Contributor

@mmichaelis mmichaelis commented Jun 25, 2016

Java deals differently for a cause of null and an unset cause. If the cause is initialized with null subsequent calls to initCause() will fail. If the cause is unset a subsequent call to initCause() works.

This solution introduces a "flag-exception" to indicate that no cause has been set and thus the cause gets only initialized if the cause has been explicitly set by the API user.

To analyze the problem you can have a look at Throwable.initCause(): If the cause is unset it's a self-reference to the exception itself and serves as indicator for cause is unset. If you call initCause with a cause already set it will fail with an IllegalStateException.


I hereby agree to the terms of the Open Test Alliance Contributor License Agreement.

Java deals differently for a cause of null and an unset
cause. If the cause is initialized with null subsequent
calls to initCause() will fail. If the cause is unset
a subsequent call to initCause() works.

This solution introduces a "flag-exception" to indicate
that no cause has been set and thus the cause gets only
initialized if the cause has been explicitly set by the API user.
@sbrannen
Copy link
Member

Good catch! 👍

Please review the newly added CONTRIBUTING guidelines.

If you agree to the CLA, please add the following lines to your pull request description:

---

I hereby agree to the terms of the Open Test Alliance Contributor License Agreement.

Thanks!

Copy link

@TWiStErRob TWiStErRob left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This would fix #70, what's missing to merge this? I would be happy to revive if author has abandoned it.

@marcphilipp marcphilipp linked an issue May 31, 2023 that may be closed by this pull request
@marcphilipp
Copy link
Member

@mmichaelis @TWiStErRob Thanks and sorry for the wait!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Cannot attach cause to AssertionFailedError even when it has none
4 participants