Close future's continuation on cancel even if future itself was not cancelled

This commit is contained in:
Nikolay Martynov 2019-02-08 16:58:54 -05:00
parent 9d830a3dab
commit 3a0a471dd5
1 changed files with 9 additions and 9 deletions

View File

@ -102,15 +102,15 @@ public final class FutureInstrumentation extends Instrumenter.Default {
public static class CanceledFutureAdvice {
@Advice.OnMethodExit(suppress = Throwable.class)
public static void exit(
@Advice.This final Future<?> future, @Advice.Return final boolean canceled) {
if (canceled) {
final ContextStore<Future, State> contextStore =
InstrumentationContext.get(Future.class, State.class);
final State state = contextStore.get(future);
if (state != null) {
state.closeContinuation();
}
public static void exit(@Advice.This final Future<?> future) {
// Try to close continuation even if future was not cancelled:
// the expectation is that continuation should be closed after 'cancel'
// is called, one way or another
final ContextStore<Future, State> contextStore =
InstrumentationContext.get(Future.class, State.class);
final State state = contextStore.get(future);
if (state != null) {
state.closeContinuation();
}
}
}