/** * Creates a retryable supplier. * * @param retry the retry context * @param supplier the original function * @param <T> the type of results supplied by this supplier * @return a retryable function */ static <T> Supplier<T> decorateSupplier(Retry retry, Supplier<T> supplier){ return () -> { Retry.Context<T> context = retry.context(); dotry { T result = supplier.get(); finalboolean validationOfResult = context.onResult(result); if (!validationOfResult) { context.onSuccess(); return result; } } catch (RuntimeException runtimeException) { context.onRuntimeError(runtimeException); } while (true); }; }