Spring / Resilience4j Interview questions
What is the difference between recordException and recordResult predicates?
A recordExceptionPredicate decides, based on the exception a call threw, whether that particular exception should count as a failure - useful when the exception type alone (say, a checked wrapper) doesn't tell the whole story and the predicate needs to inspect the exception's cause or message.
A recordResultPredicate instead inspects the call's actual return value, letting a technically successful call - one that returned normally with no exception - still be counted as a failure if its result represents a business-level failure, like an HTTP response object that came back with a 500 status code inside a 200-wrapped envelope.
Both are commonly needed together in APIs that don't always signal failure through exceptions: without a result predicate, a CircuitBreaker would have no way to detect that kind of "successful call, bad outcome" pattern at all.
More Related questions...