Close future's continuation on cancel even if future itself was not cancelled
This commit is contained in:
parent
9d830a3dab
commit
3a0a471dd5
|
@ -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();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue