Ratpack Promise add support for apply method

This commit is contained in:
Jonathan Leitschuh
2021-05-11 22:22:25 -04:00
parent b9dc3d0cfe
commit 901631ceb8
3 changed files with 25 additions and 1 deletions

View File

@@ -54,7 +54,7 @@ abstract private class SimpleFluentLambdaMethod extends FluentLambdaMethod {
private class RatpackPromiseMapMethod extends SimpleFluentLambdaMethod {
RatpackPromiseMapMethod() {
getDeclaringType() instanceof RatpackPromise and
hasName(["map", "flatMap", "blockingMap"])
hasName(["map", "flatMap", "blockingMap", "apply"])
}
override predicate consumesTaint(int lambdaArg) { lambdaArg = 0 }

View File

@@ -189,4 +189,24 @@ class Resource {
sink(value); //$hasTaintFlow
});
}
void test9() {
String tainted = taint();
Promise
.value(tainted)
.apply(Resource::identity)
.then(value -> {
sink(value); //$hasTaintFlow
});
Promise
.value("potato")
.apply(Resource::identity)
.then(value -> {
sink(value); // no taints flow
});
}
public static Promise<String> identity(Promise<String> input) {
return input.map(i -> i);
}
}

View File

@@ -113,4 +113,8 @@ public interface Promise<T> {
default Promise<T> fork() {
return null;
}
default <O> Promise<O> apply(Function<? super Promise<T>, ? extends Promise<O>> function) {
return null;
}
}