Repository navigation
Unwrap RetryableException and throw cause - #737
Conversation
|
@dinomite the builds is failing during some of the test cases. Can you please look at those and update the PR? |
| if (th instanceof RetryableException && cause != null) { | ||
| throw cause; | ||
| } | ||
| throw th; |
There was a problem hiding this comment.
This feels like we are breaking the previous signature for all feign methods and interfaces... before we would throw FeignException, now we throw Exception.
I think we could introduce a new method into the Retryer called propagateException(FeignException), and ship feign with 2 implementations.
Legacythrows the currentFeignExceptionCausethrows the root cause for aFeignException
There was a problem hiding this comment.
This is a breaking change, we should weigh that carefully.
Should we consider a mechanism similar to Hystrix Javanica?
Object process(Action action) throws Exception {
Object result;
try {
result = action.execute();
flushCache();
} catch (CommandActionExecutionException throwable) {
Throwable cause = throwable.getCause();
if (isIgnorable(cause)) {
throw new HystrixBadRequestException(cause.getMessage(), cause);
}
if (cause instanceof RuntimeException) {
throw (RuntimeException) cause;
} else if (cause instanceof Exception) {
throw (Exception) cause;
} else {
// instance of Throwable
throw new CommandActionExecutionException(cause);
}
}
return result;
}There is an assumption made that unless a particular option is set, the original exception is thrown. If the original exception cannot be thrown, it is wrapped and thrown. In Feign, we always wrap the exception. I think this is the core issue @dinomite and I have been discussing in #737. Maybe we can add a top level option or annotation to Target methods that allow for finer control over what exceptions get wrapped and what exceptions do not.
There was a problem hiding this comment.
@dinomite what are your thoughts on our suggestions?
There was a problem hiding this comment.
Thanks for reminding me that I had forgotten about this.
You're definitely right that this is big change, so doing it in a backwards-compatible way is the most tenable—I'd be ok with either @velo's suggestion of a pluggable solution or what you have suggested, @kdavisk6. I'm a bit out of context on Feign recently, do either of these look better to you all? Should Does one of them sound preferable for me to give a go at?
There was a problem hiding this comment.
We will leave that up to you to choose. The goal is to limit our exposure to existing clients.
I think we can expand on @velo's suggestion to add a new method to the Builder called propagateExceptions which will change the default Retryer registered. This will allow existing integrations to work and those that want the behavior to enable it without having to add additional code. Thoughts?
There was a problem hiding this comment.
Got it. I'll have some updates to this PR in the next week or two.
|
@kdavisk6 Sorry, traveling right now—I'll provide a proper reply next week. |
Add configuration to Feign.Builder and support in SynchronousMethodHandler to make it propagate the cause of RetryableExceptions
|
Updated—I liked the suggestion of adding propagation configuration in the builder, thanks for getting me started. The change is in |
|
Updated the README |
| private final ErrorDecoder errorDecoder; | ||
| private final boolean decode404; | ||
| private final boolean closeAfterDecode; | ||
| private final boolean propagateExceptions; |
There was a problem hiding this comment.
I like the PR and the general idea....
The only think I would ask is to replace this boolean propagateExceptions with an enum ExceptionPropagationPolicy propagationPolicy
Loved the builder. propagateExceptions() idea
There was a problem hiding this comment.
Sounds good to me, updates soon.
|
Nice, liked the new work, removed the |
|
Looks good, I will merge once build passes |
|
Hmm, looking into that error… |
* Throw cause of RetryableExceptions * Allow propogation of underlying exceptions Add configuration to Feign.Builder and support in SynchronousMethodHandler to make it propagate the cause of RetryableExceptions * Retab SMH * Add note about propagation in readme * Use enum for exception propagation policy
* Throw cause of RetryableExceptions * Allow propogation of underlying exceptions Add configuration to Feign.Builder and support in SynchronousMethodHandler to make it propagate the cause of RetryableExceptions * Retab SMH * Add note about propagation in readme * Use enum for exception propagation policy
As described in #709, this changes Feign to unwrap
RetryableExceptions to throw the underlying cause in the event retrying fails.This will require documentation updates, but I wanted to make a PR to show the changes for discussion first.