Several resilience4j rely on one or several thread-pools (via ServiceExecutor) for workload management. For instance the time-limiter will submit workloads to a thread-pool, and monitor their execution time. If they go over the time-limit, the future is cancelled (or let go) and the wrapper will throw a TimeLimiterException so as to let another workload to be processed.
It can happen that the rate at which we subject the thread-pool to new workloads outgrows the rate at which it completes and/or cancels them. When that happens, the ServiceExecutor will reject the workload, and proceed according to a policy specified by a RejectedExecutionHandler.
The default behaviour for all ServiceExecutor is to use the ThreadPoolExecutor.AbortPolicy implementation of this handler, which will throw a RejectedExecutionException. But in our case it could be interesting to at least offer the option of choosing the ThreadPoolExecutor.CallerRunsPolicy, which will make it so the thread handling the ServiceExecutor will run the workload itself (and thus, it will block submissions temporarily, possibly helping with managing workload pressure).
Several resilience4j rely on one or several thread-pools (via
ServiceExecutor) for workload management. For instance thetime-limiterwill submit workloads to a thread-pool, and monitor their execution time. If they go over the time-limit, the future is cancelled (or let go) and the wrapper will throw aTimeLimiterExceptionso as to let another workload to be processed.It can happen that the rate at which we subject the thread-pool to new workloads outgrows the rate at which it completes and/or cancels them. When that happens, the
ServiceExecutorwill reject the workload, and proceed according to a policy specified by aRejectedExecutionHandler.The default behaviour for all
ServiceExecutoris to use theThreadPoolExecutor.AbortPolicyimplementation of this handler, which will throw aRejectedExecutionException. But in our case it could be interesting to at least offer the option of choosing theThreadPoolExecutor.CallerRunsPolicy, which will make it so the thread handling theServiceExecutorwill run the workload itself (and thus, it will block submissions temporarily, possibly helping with managing workload pressure).