Skip to content

Commit

Permalink
Use the same await using syntax.
Browse files Browse the repository at this point in the history
  • Loading branch information
lukebakken committed Sep 19, 2024
1 parent 0c627c5 commit 68cc34e
Showing 1 changed file with 17 additions and 13 deletions.
30 changes: 17 additions & 13 deletions projects/RabbitMQ.Client/Impl/AutorecoveringConnection.Recovery.cs
Original file line number Diff line number Diff line change
Expand Up @@ -299,12 +299,14 @@ private async ValueTask RecoverExchangesAsync(IConnection connection,
{
try
{
var channel = await connection.CreateChannelAsync(cancellationToken: cancellationToken).ConfigureAwait(false);
await using var _ = channel.ConfigureAwait(false);
await recordedExchange.RecoverAsync(channel, cancellationToken)
.ConfigureAwait(false);
await channel.CloseAsync(cancellationToken)
.ConfigureAwait(false);
IChannel channel = await connection.CreateChannelAsync(cancellationToken: cancellationToken).ConfigureAwait(false);
await using (channel.ConfigureAwait(false))
{
await recordedExchange.RecoverAsync(channel, cancellationToken)
.ConfigureAwait(false);
await channel.CloseAsync(cancellationToken)
.ConfigureAwait(false);
}
}
catch (Exception ex)
{
Expand Down Expand Up @@ -350,7 +352,7 @@ private async Task RecoverQueuesAsync(IConnection connection,
try
{
string newName = string.Empty;
var channel = await connection.CreateChannelAsync(cancellationToken: cancellationToken).ConfigureAwait(false);
IChannel channel = await connection.CreateChannelAsync(cancellationToken: cancellationToken).ConfigureAwait(false);
await using (channel.ConfigureAwait(false))
{
newName = await recordedQueue.RecoverAsync(channel, cancellationToken)
Expand Down Expand Up @@ -463,12 +465,14 @@ private async ValueTask RecoverBindingsAsync(IConnection connection,
{
try
{
var channel = await connection.CreateChannelAsync(cancellationToken: cancellationToken).ConfigureAwait(false);
await using var _ = channel.ConfigureAwait(false);
await binding.RecoverAsync(channel, cancellationToken)
.ConfigureAwait(false);
await channel.CloseAsync(cancellationToken)
.ConfigureAwait(false);
IChannel channel = await connection.CreateChannelAsync(cancellationToken: cancellationToken).ConfigureAwait(false);
await using (channel.ConfigureAwait(false))
{
await binding.RecoverAsync(channel, cancellationToken)
.ConfigureAwait(false);
await channel.CloseAsync(cancellationToken)
.ConfigureAwait(false);
}
}
catch (Exception ex)
{
Expand Down

0 comments on commit 68cc34e

Please sign in to comment.