'Resilience4j recordFailurePredicate not working

I am trying to use recordFailurePredicate config in resilience4j in spring cloud gateway project. But could not demonstrate its functionality. My configuration is simple as below

 resilience4j.circuitbreaker:
  configs:
    default:
      slidingWindowType: COUNT_BASED
      slidingWindowSize: 10
      permittedNumberOfCallsInHalfOpenState: 3
      automaticTransitionFromOpenToHalfOpenEnabled: true
      waitDurationInOpenState: 10s
      failureRateThreshold: 50
      slowCallDurationThreshold: 300ms
      recordFailurePredicate: com.proj.test.gateway.predicate.HttpInternalServicePredicate
      slowCallRateThreshold: 50
  instances:
      MY_CIRCUIT_BREAKER:
      baseConfig: default

and im adding this instance to my route as below

  filters:
  - CircuitBreaker=MY_CIRCUIT_BREAKER

I can see that my Predicate is not being called in stack trace even if my route returns any 500 or 4xx error code.

public class HttpInternalServicePredicate implements Predicate<ResponseStatusException> {

    private static Logger LOGGER= LoggerFactory.getLogger(HttpInternalServicePredicate.class);

    @Override
    public boolean test(ResponseStatusException e) {
        LOGGER.error("HttpInternalServicePredicate entering {}",e.getStatus());
        return e.getStatus().is5xxServerError() || e.getStatus() == HttpStatus.CONFLICT;
    }
}

Am I missing something?

Thanks,



Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source