-
Notifications
You must be signed in to change notification settings - Fork 4.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
Handle not wrapped exceptions same way as all other #1567
Conversation
981fb9b
to
9fd00f8
Compare
Thanks @gagoman . Let me restate the cases to check that I understand the implications:
Those sound like the correct semantics, and what your PR implements. The piece which is broken in master is the 3rd case - it does not attempt to fallback. Did I get that right? |
Cases:
tests are:
There are no tests that cover
tests are:
as in 2nd case there are no tests that cover |
@mattrjacobs Any update on this? Should I add/change something? Thank you. |
Thanks @gagoman ! |
Hi, |
Hello. I'm not sure about your case. Could you please provide an example? Is this your case? private static class BadAndUnwrapped extends HystrixBadRequestException implements ExceptionNotWrappedByHystrix {
public BadAndUnwrapped(String message) {
super(message);
}
}
private static class Sample extends HystrixCommand<String> {
protected Sample() {
super(asKey("sample"));
}
@Override
protected String run() throws Exception {
throw new BadAndUnwrapped("expected one");
}
@Override
protected String getFallback() {
throw new RuntimeException("not expected");
}
}
public static void main(String[] args) throws Exception {
new Sample().run();
} generates next output:
Hystrix version: 1.5.12 |
Hi @gagoman, thank you for your response. Yes, it was exactly my case, I've not tried directly the |
You are right about P.S. I would suggest to debug |
Closes #1536
First of all I want to note that this change is breaking one as far as I can see.
While most of my motivation is in #1536 and I will put an overview and some extra thoughts here:
Hystrix
had that nice idea thatBadRequestException
was designed to bypass fallbacks. It was a really nice feature that allowed users ofHystrix
to make a difference between execution errors and some conditional (so called "expected") errors e.g. validation.#1414 #1503 introduced that nice concept of exception unwrapping which is really cool and I'm grateful to authors to have this feature. It has only one flaw - it has broken an idea of
BadRequestException
. Now any exception that implementsExceptionNotWrappedByHystrix
leaves no choice to user if he wants to have fallbacks available - not to use it.This PR solves this issue.
I hope I haven't broken a lot.
So the consequences of this PR:
ExceptionNotWrappedByHystrix