belliottsmith commented on code in PR #38:
URL: https://github.com/apache/cassandra-accord/pull/38#discussion_r1176975027
##########
accord-core/src/main/java/accord/utils/async/AsyncChains.java:
##########
@@ -331,6 +331,62 @@ public static <V> AsyncChain<V> failure(Throwable failure)
return new Immediate<>(failure);
}
+ public static <V, T> AsyncChain<T> map(AsyncChain<V> chain, Function<?
super V, ? extends T> mapper, Executor executor)
+ {
+ return chain.flatMap(v -> new Head<T>()
+ {
+ @Override
+ protected void start(BiConsumer<? super T, Throwable> callback)
+ {
+ try
+ {
+ executor.execute(() -> {
+ try
+ {
+ callback.accept(mapper.apply(v), null);
Review Comment:
I believe this is a potential bug, as we generally impose _precisely once_
semantics on our callbacks. If the `mapper.apply` fails we should invoke
`callback.accept(null, t)` however if `callback.accept(v, null)` fails we
should not, as the callback is now responsible for the outcome, and is expected
to be exception-safe. Anything it propagates should be ignored, as its state is
unknown to us, and no longer our responsibility.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]