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

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

Closed
Kannadasan89 opened this issue Nov 21, 2018 · 8 comments

Comments

@Kannadasan89
Copy link

Kannadasan89 commented Nov 21, 2018

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.

@ryanjbaxter
Copy link
Contributor

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

@spring-projects-issues
Copy link

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.

@Kannadasan89
Copy link
Author

Kannadasan89 commented Nov 29, 2018

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).

@ryanjbaxter
Copy link
Contributor

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.

@Kannadasan89
Copy link
Author

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

@ryanjbaxter
Copy link
Contributor

Can you try this? Netflix/Hystrix#1414

@spring-projects-issues
Copy link

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
Copy link

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.

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

No branches or pull requests

3 participants