Netflix / Hystrix

Hystrix is a latency and fault tolerance library designed to isolate points of access to remote systems, services and 3rd party libraries, stop cascading failure and enable resilience in complex distributed systems where failure is inevitable.
24.09k stars 4.7k forks source link

Replace hystrixruntimeexception in resilience4j #2060

Open rcbandit111 opened 5 months ago

rcbandit111 commented 5 months ago

I have this Hystrix code which I want to migrate to resilience4j:

  @ExceptionHandler(HystrixRuntimeException.class)
  public ResponseEntity<?> handleHystrixException(HystrixRuntimeException hystrixException) {

    if (HystrixRuntimeException.FailureType.TIMEOUT == hystrixException.getFailureType()) {
      return new InternalTimeoutException();
    }
  }

I tried this:

  @ExceptionHandler(HystrixRuntimeException.class)
  public ResponseEntity<?> handleHystrixException(HystrixRuntimeException hystrixException) {

    if (hystrixException.getCause().getCause() instanceof TimeoutException) {
      return new InternalTimeoutException();
    }
  }

I can't find how to replace HystrixRuntimeException in resilience4j. Do you know how it should be replaced?