Skip to content

Commit 48e6307

Browse files
committed
Fix TestCloseWithFaultyConsumer test by _NOT_ awaiting the CloseAsync call.
1 parent b6c43ec commit 48e6307

File tree

1 file changed

+9
-2
lines changed

1 file changed

+9
-2
lines changed

projects/Test/Integration/TestMainLoop.cs

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -75,11 +75,17 @@ public async Task TestCloseWithFaultyConsumer()
7575
QueueDeclareOk q = await _channel.QueueDeclareAsync(string.Empty, false, false, false);
7676

7777
CallbackExceptionEventArgs ea = null;
78-
_channel.CallbackExceptionAsync += async (_, evt) =>
78+
Task closeTask = null;
79+
_channel.CallbackExceptionAsync += (_, evt) =>
7980
{
8081
ea = evt;
81-
await _channel.CloseAsync();
82+
/*
83+
* NOTE:
84+
* await-ing CloseAsync here WILL result in a deadlock
85+
*/
86+
closeTask = _channel.CloseAsync();
8287
tcs.SetResult(true);
88+
return Task.CompletedTask;
8389
};
8490

8591
await _channel.BasicConsumeAsync(q, true, new FaultyConsumer(_channel));
@@ -88,6 +94,7 @@ public async Task TestCloseWithFaultyConsumer()
8894
await WaitAsync(tcs, "CallbackException");
8995

9096
Assert.NotNull(ea);
97+
await closeTask.WaitAsync(WaitSpan);
9198
Assert.False(_channel.IsOpen);
9299
Assert.Equal(200, _channel.CloseReason.ReplyCode);
93100
}

0 commit comments

Comments
 (0)