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.

Unexpected behavior when fallback methods are called

See original GitHub issue

Resilience4j version: 1.7.1 (resilience4j-spring-boot2)

Java version: 11 Spring Boot Version: 2.5.4

I tried combining @TimeLimiter and @CircuitBreaker with different fallback methods, like this:

   @Bulkhead(name = "getSearchResult", type = Type.THREADPOOL)
   @CircuitBreaker(name = "getSearchResult", fallbackMethod = "searchFailed")
   @TimeLimiter(name = "getSearchResult", fallbackMethod = "searchTimeout")
   public CompletableFuture<SearchResultData> getSearchResult(...) {...}

The two fallback methods have the same method signature as getSearchResult(...), plus a Throwable parameter.

Now, what happens is the following: In case of a timeout, searchTimeout(...) is called as expected, using a TimeoutException in the Throwable parameter. However, when no timeout occurs, but the method throws an exception, also searchTimeout(...) is called instead of searchFailed(...). The Throwable is then something else, as generated by getSearchResult(...).

Why is that? I would expect that timeouts lead to a call to searchTimeout(...) and other exceptions lead to a call to searchFailed(...).

Issue Analytics

  • State:closed
  • Created 2 years ago
  • Comments:5 (2 by maintainers)

github_iconTop GitHub Comments

1reaction
thomasschuergercommented, Oct 4, 2021

When using TimeoutException in the searchTimeout(…) method signature, it works as expected. Thrown exceptions will lead to the exceptions being caught in searchFailed(…); if often enough, searchFailed() is called with a CallNotPermittedException and the protected method is not called, as expected.

In case of a timeout, searchTimeout(…) is called. If that happens often enough, searchFailed() is called with a CallNotPermittedException and the protected method is not called, as expected.

So no bug after all.

0reactions
thomasschuergercommented, Oct 4, 2021

OK, good point. Both methods use Throwable. I’ll try using TimeoutException for searchTimeout(…).

Read more comments on GitHub >

github_iconTop Results From Across the Web

What happens if there is no fallback function in solidity?
The call will simple fail and revert. There are no security implications as everything will be reverted.
Read more >
Avoiding fallback in distributed systems - Amazon AWS
Building services that behave predictably during failures by avoiding fallback logic.
Read more >
Fallback and Human Handoff - Rasa
As users might send unexpected messages, it is possible that their behavior will lead them down unknown conversation paths.
Read more >
Unclear circuitbreak "fallback" behavior - Stack Overflow
Problem is that the fallback is called during the "closed" state, while for "open" state I still get the exception. Is this the...
Read more >
Fault tolerance with Spring - IBM Cloud Docs
The following @HystrixCommand annotation wraps the service() invocation to provide the circuit breaker behavior. The proxy calls the fallback() method if ...
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