I am using the FailSafe library to handle failures and retries.
The current implementation creates the generic FailsafeExecutor
on each run -
var result = Failsafe.with(Collections.singletonList(retryPolicy))
.with(scheduler)
.<R>getAsyncExecution(execution ->
doSomething(x, y));
FaileSafe.with
definition -
public static <R, P extends Policy<R>> FailsafeExecutor<R> with(P outerPolicy, P... policies)
Since this is called on a critical path, I would really like to avoid this (the recreation of the object).
I tried initiating the FailsafeExecutor
on the class level (the class is not generic) with a <?>
-
private final FailsafeExecutor<?> executor;
but then when calling the executor I receive -
Type parameter 'R' is not within its bound; should extend 'capture<?>'
Is there any way to get over this? Some kind of way I could make this object reusable? (same with the RetryPolicy, but I guess if there is a solution for the first it would apply for the policy as well)
Thanks.