Skip to content

Commit 48cb9e7

Browse files
committed
* Restore TestDisposedWithSocketClosedOutOfBand and don't immediately await the frame handler close.
1 parent b149964 commit 48cb9e7

File tree

1 file changed

+16
-38
lines changed

1 file changed

+16
-38
lines changed

projects/Test/Integration/TestConnectionShutdown.cs

Lines changed: 16 additions & 38 deletions
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,6 @@
3131

3232
using System;
3333
using System.IO;
34-
using System.Threading;
3534
using System.Threading.Tasks;
3635
using RabbitMQ.Client;
3736
using RabbitMQ.Client.Exceptions;
@@ -93,48 +92,27 @@ public async Task TestAbortWithSocketClosedOutOfBand()
9392
[Fact]
9493
public async Task TestDisposedWithSocketClosedOutOfBand()
9594
{
96-
await _channel.CloseAsync();
97-
await _conn.CloseAsync();
95+
var tcs = new TaskCompletionSource<bool>(TaskCreationOptions.RunContinuationsAsynchronously);
96+
97+
_channel.ChannelShutdown += (channel, args) =>
98+
{
99+
_output.WriteLine("_channel.ChannelShutdown called");
100+
tcs.SetResult(true);
101+
};
102+
103+
var c = (AutorecoveringConnection)_conn;
104+
Task frameHandlerCloseTask = c.CloseFrameHandlerAsync();
105+
98106
try
99107
{
100-
// RmqDebug.Verbose(true);
101-
// Console.SetOut(new TestOutputWriter(_output, _testDisplayName));
102-
var cf = new ConnectionFactory { AutomaticRecoveryEnabled = false };
103-
_conn = await cf.CreateConnectionAsync();
104-
_channel = await _conn.CreateChannelAsync();
105-
106-
var tcs = new TaskCompletionSource<bool>(TaskCreationOptions.RunContinuationsAsynchronously);
107-
108-
_channel.ChannelShutdown += (channel, args) =>
109-
{
110-
_output.WriteLine("_channel.ChannelShutdown called");
111-
tcs.SetResult(true);
112-
};
113-
114-
// var c = (AutorecoveringConnection)_conn;
115-
// await c.CloseFrameHandlerAsync();
116-
var c = (Connection)_conn;
117-
await c.FrameHandler.CloseAsync(CancellationToken.None);
118-
119-
try
120-
{
121-
_conn.Dispose();
122-
await WaitAsync(tcs, TimeSpan.FromSeconds(60), "channel shutdown");
123-
}
124-
finally
125-
{
126-
_conn = null;
127-
_channel = null;
128-
}
108+
_conn.Dispose();
109+
await WaitAsync(tcs, WaitSpan, "channel shutdown");
110+
await frameHandlerCloseTask.WaitAsync(WaitSpan);
129111
}
130112
finally
131113
{
132-
RmqDebug.Verbose(false);
133-
var standardOutput = new StreamWriter(Console.OpenStandardOutput())
134-
{
135-
AutoFlush = true
136-
};
137-
Console.SetOut(standardOutput);
114+
_conn = null;
115+
_channel = null;
138116
}
139117
}
140118

0 commit comments

Comments
 (0)