I am using the resilience4j library to retry some code, I have the following code below, I expect it to run 4 times. If I throw IllegalArgumentException it works but if I throw ConnectException it doesn't.
object Test extends App {
val retryConf = RetryConfig.custom()
.maxAttempts(4)
.retryOnException(_ => true)
//.retryExceptions(classOf[ConnectException])
.build
val retryRegistry = RetryRegistry.of(retryConf)
val retryConfig = retryRegistry.retry("test", retryConf)
val supplier: Supplier[Unit] = () => {
println("Run")
throw new IllegalArgumentException("Test")
//throw new ConnectException("Test")
}
val decoratedSupplier = Decorators.ofSupplier(supplier).withRetry(retryConfig).get()
}
I expected that retry to retry on all exceptions.