@Override protected Promise<? extends T> run(Context context) throws Throwable { return func.apply(context); } };
default <V> Function8<T1, T2, T3, T4, T5, T6, T7, T8, V> andThen(Function1<? super R, ? extends V> f) { Objects.requireNonNull(f); return (T1 t1, T2 t2, T3 t3, T4 t4, T5 t5, T6 t6, T7 t7, T8 t8) -> f.apply(apply(t1, t2, t3, t4, t5, t6, t7, t8)); }
default <V> Function7<T1, T2, T3, T4, T5, T6, T7, V> andThen(Function1<? super R, ? extends V> f) { Objects.requireNonNull(f); return (T1 t1, T2 t2, T3 t3, T4 t4, T5 t5, T6 t6, T7 t7) -> f.apply(apply(t1, t2, t3, t4, t5, t6, t7)); }
private static Object coerceValue(String property, Object value) throws RequestConfigKeyParsingException { try { switch(property) { case "timeoutMs": return ConfigValueCoercers.LONG.apply(value); case "batchingEnabled": return ConfigValueCoercers.BOOLEAN.apply(value); case "maxBatchSize": return ConfigValueCoercers.INTEGER.apply(value); default: throw new RequestConfigKeyParsingException("Internal error: parsed config contains unsupported property: " + property); } } catch (Exception e) { throw new RequestConfigKeyParsingException(e); } }
default <V> Function2<T1, T2, V> andThen(Function1<? super R, ? extends V> f) { Objects.requireNonNull(f); return (T1 t1, T2 t2) -> f.apply(apply(t1, t2)); }
default <V> Function13<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, V> andThen(Function1<? super R, ? extends V> f) { Objects.requireNonNull(f); return (T1 t1, T2 t2, T3 t3, T4 t4, T5 t5, T6 t6, T7 t7, T8 t8, T9 t9, T10 t10, T11 t11, T12 t12, T13 t13) -> f.apply(apply(t1, t2, t3, t4, t5, t6, t7, t8, t9, t10, t11, t12, t13)); }
default <V> Function3<T1, T2, T3, V> andThen(Function1<? super R, ? extends V> f) { Objects.requireNonNull(f); return (T1 t1, T2 t2, T3 t3) -> f.apply(apply(t1, t2, t3)); }
default <V> Function11<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, V> andThen(Function1<? super R, ? extends V> f) { Objects.requireNonNull(f); return (T1 t1, T2 t2, T3 t3, T4 t4, T5 t5, T6 t6, T7 t7, T8 t8, T9 t9, T10 t10, T11 t11) -> f.apply(apply(t1, t2, t3, t4, t5, t6, t7, t8, t9, t10, t11)); }
default <V> Function10<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, V> andThen(Function1<? super R, ? extends V> f) { Objects.requireNonNull(f); return (T1 t1, T2 t2, T3 t3, T4 t4, T5 t5, T6 t6, T7 t7, T8 t8, T9 t9, T10 t10) -> f.apply(apply(t1, t2, t3, t4, t5, t6, t7, t8, t9, t10)); }
default <V> Function6<T1, T2, T3, T4, T5, T6, V> andThen(Function1<? super R, ? extends V> f) { Objects.requireNonNull(f); return (T1 t1, T2 t2, T3 t3, T4 t4, T5 t5, T6 t6) -> f.apply(apply(t1, t2, t3, t4, t5, t6)); }
default <V> Function4<T1, T2, T3, T4, V> andThen(Function1<? super R, ? extends V> f) { Objects.requireNonNull(f); return (T1 t1, T2 t2, T3 t3, T4 t4) -> f.apply(apply(t1, t2, t3, t4)); }
default <V> Function15<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14, T15, V> andThen(Function1<? super R, ? extends V> f) { Objects.requireNonNull(f); return (T1 t1, T2 t2, T3 t3, T4 t4, T5 t5, T6 t6, T7 t7, T8 t8, T9 t9, T10 t10, T11 t11, T12 t12, T13 t13, T14 t14, T15 t15) -> f.apply(apply(t1, t2, t3, t4, t5, t6, t7, t8, t9, t10, t11, t12, t13, t14, t15)); }
default <V> Function5<T1, T2, T3, T4, T5, V> andThen(Function1<? super R, ? extends V> f) { Objects.requireNonNull(f); return (T1 t1, T2 t2, T3 t3, T4 t4, T5 t5) -> f.apply(apply(t1, t2, t3, t4, t5)); }
default <V> Function12<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, V> andThen(Function1<? super R, ? extends V> f) { Objects.requireNonNull(f); return (T1 t1, T2 t2, T3 t3, T4 t4, T5 t5, T6 t6, T7 t7, T8 t8, T9 t9, T10 t10, T11 t11, T12 t12) -> f.apply(apply(t1, t2, t3, t4, t5, t6, t7, t8, t9, t10, t11, t12)); }
default <V> Function9<T1, T2, T3, T4, T5, T6, T7, T8, T9, V> andThen(Function1<? super R, ? extends V> f) { Objects.requireNonNull(f); return (T1 t1, T2 t2, T3 t3, T4 t4, T5 t5, T6 t6, T7 t7, T8 t8, T9 t9) -> f.apply(apply(t1, t2, t3, t4, t5, t6, t7, t8, t9)); }
default <V> Function14<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14, V> andThen(Function1<? super R, ? extends V> f) { Objects.requireNonNull(f); return (T1 t1, T2 t2, T3 t3, T4 t4, T5 t5, T6 t6, T7 t7, T8 t8, T9 t9, T10 t10, T11 t11, T12 t12, T13 t13, T14 t14) -> f.apply(apply(t1, t2, t3, t4, t5, t6, t7, t8, t9, t10, t11, t12, t13, t14)); }
@Override public void accept(Promise<S> src, Settable<T> dst) { if (src.isFailed()) { dst.fail(src.getError()); } else { try { dst.done(_transform.apply(src.get())); } catch (Throwable t) { dst.fail(t); } } }
if (!(Exceptions.isCancellation(that.getError()))) { try { Task<T> r = func.apply(that.getError()); if (r == null) { throw new RuntimeException(desc + " returned null");
/** Create a wrapped task with associated recovery task that will retry if necessary. */ private Task<T> wrap(int attempt) { Task<T> retryTask = Task.async(_policy.getName() + ", attempt " + attempt, context -> { final SettablePromise<T> result = Promises.settable(); Task<T> task = _taskFunction.apply(attempt); final Task<T> recovery = Task.async(_name + " recovery", recoveryContext -> { final SettablePromise<T> recoveryResult = Promises.settable(); if (task.isFailed()) { // Failed task will cause retry to be scheduled. ErrorClassification errorClassification = _policy.getErrorClassifier().apply(task.getError()); retry(attempt + 1, task.getError(), errorClassification, recoveryContext, recoveryResult); } else { recoveryResult.done(task.get()); } return recoveryResult; }); // Recovery task should run immediately after the original task to process its error. recovery.setPriority(Priority.MAX_PRIORITY); recovery.getShallowTraceBuilder().setSystemHidden(true); Promises.propagateResult(recovery, result); context.after(task).run(recovery); context.run(task); return result; }); retryTask.getShallowTraceBuilder().setTaskType(TaskType.RETRY.getName()); return retryTask; }