A zero-dependency Java library wraps executable logic with composable resilience policies such as retry, circuit breaking, and timeouts.
Overview
Failsafe helps Java applications survive intermittent failures by applying policies around runnables and suppliers. The API is built for everyday cases while still allowing layered compositions when requirements grow more complex.
Policies include Retry, CircuitBreaker, RateLimiter, Timeout, Bulkhead, and Fallback. Additional modules integrate with OkHttp and Retrofit. You define which exceptions or conditions trigger handling, then run or get results synchronously or through CompletableFuture-style async execution.
Multiple policies can be combined in a defined order so fallbacks, retries, breakers, and timeouts cooperate on the same call path. Compositions can be stored in a FailsafeExecutor for reuse across the codebase.
Documentation on failsafe.dev covers setup by adding the dependency to a project, building policies with the builder pattern, and deeper policy behavior including composition ordering.
Key features
- Retry policy with delays and limits
- Circuit breaker support
- Rate limiter and timeout policies
- Bulkhead and fallback handling
- Sync and async execution
- Composable policy stacks
- Reusable FailsafeExecutor
- OkHttp and Retrofit modules
Use cases
- Retrying failed network connections
- Guarding services with circuit breakers
- Enforcing call timeouts in Java
- Layering fallback logic on suppliers
- Async resilient CompletableFuture calls