question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Error response returned by the server is ignored by resilience4j

See original GitHub issue

Hi

I am using the resilience4j with Feign client for communication with another server (lets say it is running on localhost:8090 with 1 exposed endpoint i.e. /sample). I am testing a case when I want to record only specific exceptions from the underlying http client library. So following is my config:

resilience4j.circuitbreaker:
  configs:
    default:
      registerHealthIndicator: true
      ringBufferSizeInClosedState: 4
      ringBufferSizeInHalfOpenState: 2
      automaticTransitionFromOpenToHalfOpenEnabled: true
      waitDurationInOpenState: 20s
      failureRateThreshold: 50
      eventConsumerBufferSize: 10
      ignoreExceptions:
        - com.resilience4j.exception.BusinessException
      recordExceptions:
        - java.net.SocketTimeoutException
        - feign.RetryableException

Now when the /sample endpoint returns a response with http status 400, which is a valid case and due to incorrect data passed. The /sample endpoint returns the following response if called separately

{
    "message": "this is a bad request"
}

But the resilience4j library ignores this response and returns the following response:

{
    "timestamp": "2019-08-14T09:40:00.568+0000",
    "status": 500,
    "error": "Internal Server Error",
    "message": "status 400 reading MyFeignClient#feignMessage()",
    "path": "/resilience4j/feignClient"
}

How can I preserve the original response returned by the other server?

Issue Analytics

  • State:closed
  • Created 4 years ago
  • Comments:6 (6 by maintainers)

github_iconTop GitHub Comments

3reactions
RobWincommented, Aug 14, 2019

recordExceptions: Configures a list of classes that are recorded as a failure and thus increase the failure rate. Any exception matching or inheriting from one of the list should count as a failure, unless ignored via ignoreExceptions. All other exceptions are not recorded, which means that they are ignored and thus do not count as success nor failure. If you add an exception to recordExceptions it’s like: ignore all exceptions except this one. If you add an exception to ignoreExceptions it’s like: record all exceptions except this one.

The combination of ignoreExceptions and recordExceptions is helpful when you want to handle inheritance. For example: ignoreExceptions(Exception.class) and recordExceptions(Throwable.class) would record java.lang.Error as a failure.

0reactions
RobWincommented, Aug 16, 2019

Closed in favor of #568

Read more comments on GitHub >

github_iconTop Results From Across the Web

How to Prevent Certain Exceptions from Tripping a ...
The Resilience4j circuit breaker by default considers any exception thrown inside of the Supplier as a failure. If over 50% of the calls...
Read more >
Failover and Circuit Breaker with Resilience4j | by Rob Golder
In this demo application, if the secondary 3PP lookup fails, then that exception will be returned to the client of this service. It...
Read more >
NoSuchMethodException in resilience4j fallback with spring ...
I tried to implement this technology with eureka server but get stuck at this fallback method point. my pom.xml <?xml version="1.0" encoding=" ...
Read more >
CircuitBreaker - resilience4j
The Predicate must return true if the exception should be ignored. The Predicate must return false, if the exception should count as a...
Read more >
Implementing Retry with Resilience4j - Reflectoring
We have two options when a remote operation fails - immediately return an error to our client, or retry the operation.
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found