Skip to content

Commit 426c6c3

Browse files
committed
Unset sync context in CallingThreadDispatcher unconditionally.
1 parent f912afb commit 426c6c3

File tree

1 file changed

+5
-7
lines changed

1 file changed

+5
-7
lines changed

src/core/Akka.TestKit/CallingThreadDispatcher.cs

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -58,13 +58,11 @@ protected override void ExecuteTask(IRunnable run)
5858

5959
try
6060
{
61-
// Actors should not run with ActorCellKeepingSynchronizationContext otherwise continuations in
62-
// async message handlers will use ActorCellKeepingSynchronizationContext instead of ActorTaskScheduler
63-
// which cause ActorContext to be incorrect.
64-
if (currentSyncContext is ActorCellKeepingSynchronizationContext)
65-
{
66-
SynchronizationContext.SetSynchronizationContext(null);
67-
}
61+
// Actors should not run with ActorCellKeepingSynchronizationContext
62+
// (or any sync context that wraps ActorCellKeepingSynchronizationContext, e.g. Xunit's AsyncTestSyncContext)
63+
// otherwise continuations in async message handlers will use ActorCellKeepingSynchronizationContext
64+
// instead of ActorTaskScheduler which causes ActorContext to be incorrect.
65+
SynchronizationContext.SetSynchronizationContext(null);
6866

6967
run.Run();
7068
}

0 commit comments

Comments
 (0)