Skip to content

Commit 68cc34e

Browse files
committed
Use the same await using syntax.
1 parent 0c627c5 commit 68cc34e

File tree

1 file changed

+17
-13
lines changed

1 file changed

+17
-13
lines changed

projects/RabbitMQ.Client/Impl/AutorecoveringConnection.Recovery.cs

Lines changed: 17 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -299,12 +299,14 @@ private async ValueTask RecoverExchangesAsync(IConnection connection,
299299
{
300300
try
301301
{
302-
var channel = await connection.CreateChannelAsync(cancellationToken: cancellationToken).ConfigureAwait(false);
303-
await using var _ = channel.ConfigureAwait(false);
304-
await recordedExchange.RecoverAsync(channel, cancellationToken)
305-
.ConfigureAwait(false);
306-
await channel.CloseAsync(cancellationToken)
307-
.ConfigureAwait(false);
302+
IChannel channel = await connection.CreateChannelAsync(cancellationToken: cancellationToken).ConfigureAwait(false);
303+
await using (channel.ConfigureAwait(false))
304+
{
305+
await recordedExchange.RecoverAsync(channel, cancellationToken)
306+
.ConfigureAwait(false);
307+
await channel.CloseAsync(cancellationToken)
308+
.ConfigureAwait(false);
309+
}
308310
}
309311
catch (Exception ex)
310312
{
@@ -350,7 +352,7 @@ private async Task RecoverQueuesAsync(IConnection connection,
350352
try
351353
{
352354
string newName = string.Empty;
353-
var channel = await connection.CreateChannelAsync(cancellationToken: cancellationToken).ConfigureAwait(false);
355+
IChannel channel = await connection.CreateChannelAsync(cancellationToken: cancellationToken).ConfigureAwait(false);
354356
await using (channel.ConfigureAwait(false))
355357
{
356358
newName = await recordedQueue.RecoverAsync(channel, cancellationToken)
@@ -463,12 +465,14 @@ private async ValueTask RecoverBindingsAsync(IConnection connection,
463465
{
464466
try
465467
{
466-
var channel = await connection.CreateChannelAsync(cancellationToken: cancellationToken).ConfigureAwait(false);
467-
await using var _ = channel.ConfigureAwait(false);
468-
await binding.RecoverAsync(channel, cancellationToken)
469-
.ConfigureAwait(false);
470-
await channel.CloseAsync(cancellationToken)
471-
.ConfigureAwait(false);
468+
IChannel channel = await connection.CreateChannelAsync(cancellationToken: cancellationToken).ConfigureAwait(false);
469+
await using (channel.ConfigureAwait(false))
470+
{
471+
await binding.RecoverAsync(channel, cancellationToken)
472+
.ConfigureAwait(false);
473+
await channel.CloseAsync(cancellationToken)
474+
.ConfigureAwait(false);
475+
}
472476
}
473477
catch (Exception ex)
474478
{

0 commit comments

Comments
 (0)