-
Notifications
You must be signed in to change notification settings - Fork 2.7k
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
Unwrap InvocationTargetException thrown by QuarkusTest*Callback #23989
Conversation
Map.Entry<Class<?>, ?> tuple = createQuarkusTestMethodContextTuple(context); | ||
afterEachCallback.getClass().getMethod("afterEach", tuple.getKey()) | ||
.invoke(afterEachCallback, tuple.getValue()); | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Running this outside of the TCCL restoration block looked wrong, so I moved it inside.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hm... Not sure about this... Did you see an issue with the existing code?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Not an actual one, but compare it with this:
https://github.com/quarkusio/quarkus/blob/2.7.2.Final/test-framework/junit5/src/main/java/io/quarkus/test/junit/QuarkusTestExtension.java#L407
Why should the TCCL only be restored if there is an exception in a beforeEachCallback, but not if there is an exception in an afterEachCallback? Doesn't make sense to me.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
PS: afterAll also restores the TCCL just like beforeEach. Same happens for beforeClassCallback. 🤷♂️
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This change looks right to me
I'll add the backport label because I think that TCCL thing is a bug (rare though). |
Improves readability when you have e.g. a custom callback that validates something.
Some methods are only allowed to throw
Exeption
, notThrowable
, hence the cause type check.