Spring / Resilience4j Interview questions
Why do we use recordExceptions versus ignoreExceptions?
Both control which thrown exceptions the CircuitBreaker counts as a failure, but they express the intent from opposite directions and are meant to be used situationally, not both at once for the same exception.
recordExceptions is an allow-list: only the listed exception types (and their subclasses) count against the failure rate, everything else passes through uncounted - useful when you know exactly which exceptions represent a genuine dependency problem, like a connection timeout.
ignoreExceptions is a deny-list: every exception counts as a failure except the ones listed, which is useful for excluding expected, business-level exceptions - like a validation error - that indicate the caller's request was invalid, not that the dependency is unhealthy.
Using an ignore list is generally preferred when a service throws many domain-specific exceptions, since it avoids having to enumerate every legitimate failure type individually.
More Related questions...