Caused by: java.lang.RuntimeException: Hystrix circuit short-circuited and is OPEN for HystrixBadRequestException
I am using Feign-client along with Hystrix and i have custom error decoder where i am returning HystrixBadRequestException only for client errors and catching the exceptions in a method TestController:getInfo() as below. In this case, it should not trigger a fallback and should not open the circuit(i.e should disable the circuit breaker), but is not working as expected. and in javadoc also mentioned few comments about it. Link: https://netflix.github.io/Hystrix/javadoc/com/netflix/hystrix/exception/HystrixBadRequestException.html
Please find the attached sample source code. feign-client-fallback-test.zip
Here, from feign-client-test project, you can use RestClient to simulate an issues.
Can you tell me how to simulate the issue with your sample?
If you would like us to look at this issue, please provide the requested information. If the information is not provided within the next 7 days this issue will be closed.
Please find the minimal steps to simulate the behavior:-
- Run the version-info-service spring boot service
- Run the feign-client-test spring boot service
- Use RestClient class from feign-client-test project(com.test.fc) to send the request/simulate. So this client will basically create a some loads to simulate the behavior
- So, Here i am saving the fallback information as soon as fallback is triggered. Using an endpoint : http://localhost:8090/getFallbackDetail send a request from client like postman etc.. to know/identify whether the fallback is triggered or not. If return value is empty, then please try again to simulate. If return value is not empty and it confirms that fallback is called (but idea is to should not happen).
If HystrixBadRequestException is thrown by the HystrixCommand than the fallback will not be triggered. However all you are doing here is catching the exception. The Feign client would have to throw a HystrixBadRequestException as it is the thing wrapped in a HystrixCommand. However due to the way Spring Cloud Feign works that is not possible.
Do you think, Is there a way to avoid calling fallback and breaking circuit for 4xx client errors. I have tried few things based on your last comments as below, but nothing works as expected.
1.
try {
// calling client here
catch(HystrixBadRequestException ex) {
throw ex;
}
2. or Directly throwing an exception from feignErrorDecoder for 4xx errors
Can you try this? https://github.com/Netflix/Hystrix/pull/1414
If you would like us to look at this issue, please provide the requested information. If the information is not provided within the next 7 days this issue will be closed.
Closing due to lack of requested feedback. If you would like us to look at this issue, please provide the requested information and we will re-open the issue.