_policy = policy;
_taskFunction = taskFunction;
}
public static <U> Task<U> withRetryPolicy(String name, RetryPolicy policy, Function1<Integer, Task<U>> taskFunction) {
RetriableTask<U> retriableTask = new RetriableTask<>(name, policy, taskFunction);
<BUG>return Task.async(name + " retriableTask", retriableTask::run);

}</BUG>
private Task<T> wrap(int attempt) {
<BUG>return Task.async(_policy.getName() + ", attempt " + attempt, context -> {
</BUG>
final SettablePromise<T> result = Promises.settable();

_policy = policy;
_taskFunction = taskFunction;
}
public static <U> Task<U> withRetryPolicy(String name, RetryPolicy policy, Function1<Integer, Task<U>> taskFunction) {
RetriableTask<U> retriableTask = new RetriableTask<>(name, policy, taskFunction);
Task<U> retryTaskWrapper = Task.async(name + " retriableTask", retriableTask::run);
retryTaskWrapper.getShallowTraceBuilder().setTaskType(TaskType.WITH_RETRY.getName());
return retryTaskWrapper;
}
private Task<T> wrap(int attempt) {
Task<T> retryTask = Task.async(_policy.getName() + ", attempt " + attempt, context -> {
final SettablePromise<T> result = Promises.settable();
