Spring / Resilience4j Interview questions
What is the purpose of the Decorators class?
The Decorators class provides a fluent builder for composing multiple resilience patterns around a single call, without hand-nesting one decorator function inside another.
Instead of writing CircuitBreaker.decorateSupplier(cb, RateLimiter.decorateSupplier(rl, supplier)) by hand, you write Decorators.ofSupplier(supplier).withCircuitBreaker(cb).withRateLimiter(rl).decorate(), which reads top-to-bottom and keeps the composition order explicit and easy to change.
It supports every core module - CircuitBreaker, Retry, RateLimiter, Bulkhead, TimeLimiter, Cache, and even a plain fallback - and works with Supplier, Runnable, Function, and CompletionStage-based calls alike.
More Related questions...