diff --git a/test/Grains/TestGrains/DeadlockGrain.cs b/test/Grains/TestGrains/DeadlockGrain.cs index 4e000e9e280..e3ffae92674 100644 --- a/test/Grains/TestGrains/DeadlockGrain.cs +++ b/test/Grains/TestGrains/DeadlockGrain.cs @@ -85,6 +85,7 @@ public class CallChainReentrancyGrain : Grain, ICallChainReentrancyGrain public async Task CallChain(ICallChainObserver observer, List<(string TargetGrain, ReentrancyCallType CallType)> callChain, int callIndex, CancellationToken cancellationToken = default) { cancellationToken.ThrowIfCancellationRequested(); + var unblocker = _unblocker; await observer.OnEnter(Id, callIndex); try { @@ -100,19 +101,19 @@ public async Task CallChain(ICallChainObserver observer, List<(string TargetGrai switch (op.CallType) { case ReentrancyCallType.Regular: - await Task.WhenAny(_unblocker.Task, target.CallChain(observer, newChain, nextCallIndex, cancellationToken)); + await Task.WhenAny(unblocker.Task, target.CallChain(observer, newChain, nextCallIndex, cancellationToken)); break; case ReentrancyCallType.AllowCallChainReentrancy: { using var _ = RequestContext.AllowCallChainReentrancy(); - await Task.WhenAny(_unblocker.Task, target.CallChain(observer, newChain, nextCallIndex, cancellationToken)); + await Task.WhenAny(unblocker.Task, target.CallChain(observer, newChain, nextCallIndex, cancellationToken)); break; } case ReentrancyCallType.SuppressCallChainReentrancy: { using var _ = RequestContext.SuppressCallChainReentrancy(); - await Task.WhenAny(_unblocker.Task, target.CallChain(observer, newChain, nextCallIndex, cancellationToken)); + await Task.WhenAny(unblocker.Task, target.CallChain(observer, newChain, nextCallIndex, cancellationToken)); break; } }