spring-cloud-openfeign icon indicating copy to clipboard operation
spring-cloud-openfeign copied to clipboard

Caused by: java.lang.RuntimeException: Hystrix circuit short-circuited and is OPEN for HystrixBadRequestException

Open Kannadasan89 opened this issue 8 years ago • 8 comments

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.

Kannadasan89 avatar Nov 21 '18 11:11 Kannadasan89

Can you tell me how to simulate the issue with your sample?

ryanjbaxter avatar Nov 21 '18 14:11 ryanjbaxter

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.

spring-projects-issues avatar Nov 28 '18 14:11 spring-projects-issues

Please find the minimal steps to simulate the behavior:-

  1. Run the version-info-service spring boot service
  2. Run the feign-client-test spring boot service
  3. 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
  4. 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).

Kannadasan89 avatar Nov 29 '18 11:11 Kannadasan89

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.

ryanjbaxter avatar Nov 29 '18 13:11 ryanjbaxter

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

Kannadasan89 avatar Dec 06 '18 03:12 Kannadasan89

Can you try this? https://github.com/Netflix/Hystrix/pull/1414

ryanjbaxter avatar Dec 06 '18 17:12 ryanjbaxter

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.

spring-projects-issues avatar Dec 13 '18 17:12 spring-projects-issues

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.

spring-projects-issues avatar Dec 20 '18 17:12 spring-projects-issues