Closed ttim closed 3 years ago
LGTM, both onComplete vs andThen are for performing side-effects when the Future is done. But andThen makes it so the side-effect runs before anything else. Seems like exactly what we wanted in this case.
@johnynek does it seem reasonable to you? I'm wondering is there something I missing
Currently
writer.finished
happens inonComplete
callback onFuture
result inExucution
. However sinceonComplete
isn't being called before future being resolved and called asynchroniously after future being resolved, it leads to a race and runtime error:main
executesExecution
onComplete
withwriter.finished
is being scheduledFuture
gets resolved and jvm starts to shutdownwriter.finished
starts to execute and in case of cascading backend adds shutdown hookTo fix this behaviour I made
onComplete
logic to happen before result future get resolved by changingonComplete
toandThen