Close future's continuation on cancel even if future itself was not cancelled
@@ -102,9 +102,10 @@ 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) {
+ 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);
@@ -114,4 +115,3 @@ public final class FutureInstrumentation extends Instrumenter.Default {
}
}
}
-}
