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

Custom ErrorDecoder and RetryableExceptions #703

Closed
Kidlike opened this issue May 16, 2018 · 11 comments
Closed

Custom ErrorDecoder and RetryableExceptions #703

Kidlike opened this issue May 16, 2018 · 11 comments
Labels
help wanted Issues we need help with tackling

Comments

@Kidlike
Copy link

Kidlike commented May 16, 2018

I have set up a custom ErrorDecoder which is used for all 4xx responses, but for example if the inbound server is down, my custom ErrorDecoder is never used, and instead just a RetryableException is thrown.

Is there something else I could override that will control what exception is thrown regardless of the scenario ?

Also something like this would help to create better logs... Now the logs are inconsistent because of this conditionality.

@kdavisk6
Copy link
Member

I suspect that the Client instance you have configured is set up to automatically retry connection based exceptions. Do you have an example of the Builder configuration you used?

@Kidlike
Copy link
Author

Kidlike commented May 16, 2018

Sorry forgot to mention I use org.springframework.cloud.netflix.feign.FeignClient:

@FeignClient(name = "filerepo", url = "${filerepo.host}")

@kdavisk6
Copy link
Member

That is a special Spring version of an auto-configured Feign client. Have you asked your question with the Spring Cloud folks? There are too many variables there for me to help you out. For example, you can manually configure a Client, or used the default one that Spring gives you, which is based on a number of different scenarios.

I suggest that you check with them first and see if there is something you can audit or update in your Spring configuration first.

@Kidlike
Copy link
Author

Kidlike commented May 16, 2018

Thanks, I will investigate from the Spring side of things :)

@Squiry
Copy link

Squiry commented Jun 1, 2018

@kdavisk6 It's the issue with default SynchronousMethodHandler, not with Spring Cloud.
SynchronousMethodHandler invokes ErrorDecoder in case of http response only. If there's no http response (IOException thrown by Client) then it wrappes exception with RetryableException and throws it. code

@Kidlike
Copy link
Author

Kidlike commented Jun 1, 2018

@Squiry Nice catch :)

Any suggestions?

@Squiry
Copy link

Squiry commented Jun 1, 2018

Well ErrorDecoder should decode erros and there's nothing to decode anyway.
You can proxy Client and handle IOException there if you really need it. Or you can just handle RetryableException.

@Kidlike
Copy link
Author

Kidlike commented Jun 1, 2018

Yeah at the moment I'm just handling RetryableException. I guess I'll stay like this. Thanks though !

@kdavisk6
Copy link
Member

kdavisk6 commented Jul 4, 2018

The current implementation treats all IOExceptions from the Client as something related to the communication and should be retried. This will continue for the maxAttempts and then throw the RetryableException out, if you use the default Retryer. If this is not the behavior you want, you can implement your own Retryer and process them accordingly.

@kdavisk6
Copy link
Member

Closing based on the last comment.

@shavkat1121
Copy link

thanks

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
help wanted Issues we need help with tackling
Projects
None yet
Development

No branches or pull requests

4 participants