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

Hystrix Javanica not wrapping any exceptions #1285

Closed
smjdowling opened this issue Jul 20, 2016 · 11 comments
Closed

Hystrix Javanica not wrapping any exceptions #1285

smjdowling opened this issue Jul 20, 2016 · 11 comments
Labels

Comments

@smjdowling
Copy link

Steps to reproduce:
In a HystrixCommand throw a new exception

Expected:
Exceptions should be wrapped in HystrixRuntimeException or HystrixBadRequestException (if ignored).

Actual:
The exception isn't wrapped -- the thrown exception is propagated instead of a wrapped exception.

@smjdowling
Copy link
Author

related to #1273

@mattrjacobs
Copy link
Contributor

Is this in master, or in a released version of Hystrix?

@smjdowling
Copy link
Author

smjdowling commented Jul 25, 2016

@mattrjacobs in master after testing the changes from pr #1273. Thanks.

@jbojar
Copy link

jbojar commented Aug 2, 2016

@smjdowling Are you sure that exceptions should be wrapped if using HystrixCommandAspect from javanica? Unwrapping from HystrixRuntimeException was added in HystrixCommandAspect in commit 155d4e9 and unwrapping from HystrixBadRequestException even earlier in commit 59bbe9f.

@dmgcodevil
Copy link
Contributor

hi, @smjdowling , @jbojar thanks for the answer, yes, I removed the logic to wrap original exceptions in corresponding hystrix exceptions, because throwing hystrix exceptions makes error handling awkward in spring framework. see iss993

@michaelcowan
Copy link
Contributor

michaelcowan commented Sep 13, 2016

I understand the idea of making Javanica as transparent as possible, however personally I prefer to keep things more Hystrix like and not assume anything. Perhaps using an annotation argument to allow choosing if causes should be raised would be an idea?

What concerns me more than my preference though, is that I can't see how the tests can possibly be testing ignoreExceptions. If an exception is ignored, then expected is that exception. If an exception is not ignored, then expected used to be HystrixRuntimeException but is now that exception. There is no difference. (See BasicDefaultIgnoreExceptionsTest.java)

@dmgcodevil
Copy link
Contributor

@michaelcowan , regarding ignored exceptions. Yes it's expected behaviour to get user exception regardless whether it's ignored or not. Throwing hystrix exceptions is pointless for most users. To test ignored exceptions you should check command metrics/events to verify that fallback wasn't triggered. It's easy to do. The whole point of javanica is making your code doesn't depend on hystrix platform so that you can change this lib in the future without changing your code. Throwing platform specific exceptions is kind of leaking abstraction.

@michaelcowan
Copy link
Contributor

@dmgcodevil I totally see where you are coming from. It is much more elegant and hugely simplified for most users - its just that now this is the only way. For me personally Javanica was simply a convenient way to integrate Hystrix without having to hand roll lots of command classes.

How would you feel about something like this?

Were you suggesting to check the command events in a unit test? How would you go about this?

@dmgcodevil
Copy link
Contributor

@michaelcowan I'll take a look and answer latter

@dmgcodevil
Copy link
Contributor

dmgcodevil commented Sep 14, 2016

Were you suggesting to check the command events in a unit test? How would you go about this?

something like this:

 HystrixInvokableInfo<?> command = HystrixRequestLog.getCurrentRequest()
                .getAllExecutedCommands().iterator().next();
        // confirm that command has failed
        assertTrue(command.getExecutionEvents().contains(HystrixEventType.FAILURE));
        // and that fallback was successful
        assertTrue(command.getExecutionEvents().contains(HystrixEventType.FALLBACK_SUCCESS));

@michaelcowan let's continue discussion here

@mattrjacobs
Copy link
Contributor

I think this has been closed by PRs since this issue was raised. If there are still open questions, please re-open.

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

No branches or pull requests

5 participants