in src/main/java/com/spotify/futures/FuturesExtra.java [137:155]
public static <A, B> ListenableFuture<A> fastFail(
final ListenableFuture<B> conditionValue,
final ListenableFuture<A> future,
final Validator<B> validator,
final Executor executor) {
return Futures.transformAsync(
conditionValue,
value -> {
try {
validator.validate(value);
return future;
} catch (Exception e) {
future.cancel(false);
throw e;
}
},
executor);
}