4

I'm using Spring Cloud Circuit Breaker 2.0.0 (resilience4j implementation) for circuit breaking in my application. Let's say a have method define like this:

String doStuff() {
  ...
  // Oh no, something went wrong
  throw new SomethingWentWrongException();
  ...
}

I wrap doStuff in the circuit breaker:

return circuitBreakerFactory.create("doStuff").run(() -> doStuff());

When SomethingWentWrongException is thrown, and I haven't declared a fallback for the circuit breaker, then SomethingWentWrongException will be wrapped in an instance of org.springframework.cloud.client.circuitbreaker.NoFallbackAvailableException as the "cause".

My question is: Is there anyway to configure so that Spring Cloud CircuitBreaker doesn't wrap SomethingWentWrongException in NoFallbackAvailableException and simply just throws the SomethingWentWrongException instead.

Johan
  • 37,479
  • 32
  • 149
  • 237

0 Answers0