Skip to content

Minor cleanup in AutoRecovery classes #1670

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 3 commits into from
Sep 11, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions projects/RabbitMQ.Client/client/impl/AutorecoveringChannel.cs
Original file line number Diff line number Diff line change
Expand Up @@ -197,7 +197,7 @@ await newChannel.TxSelectAsync(cancellationToken)

if (_disposed)
{
await newChannel.AbortAsync()
await newChannel.AbortAsync(CancellationToken.None)
.ConfigureAwait(false);
return false;
}
Expand All @@ -207,7 +207,7 @@ await newChannel.AbortAsync()

if (recoverConsumers)
{
await _connection.RecoverConsumersAsync(this, newChannel, recordedEntitiesSemaphoreHeld)
await _connection.RecoverConsumersAsync(this, newChannel, recordedEntitiesSemaphoreHeld, cancellationToken)
.ConfigureAwait(false);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -77,8 +77,7 @@ static bool ShouldTriggerConnectionRecovery(ShutdownEventArgs args)
* https://github.com/rabbitmq/rabbitmq-dotnet-client/issues/826
* Happens when an AppDomain is unloaded
*/
if (args.Exception is ThreadAbortException &&
args.ReplyCode == Constants.InternalError)
if (args is { Exception: ThreadAbortException, ReplyCode: Constants.InternalError })
{
return false;
}
Expand Down Expand Up @@ -407,7 +406,7 @@ await _config.TopologyRecoveryExceptionHandler.QueueRecoveryExceptionHandlerAsyn
}
finally
{
await _recordedEntitiesSemaphore.WaitAsync()
await _recordedEntitiesSemaphore.WaitAsync(cancellationToken)
.ConfigureAwait(false);
}
}
Expand Down Expand Up @@ -494,7 +493,7 @@ await _recordedEntitiesSemaphore.WaitAsync(cancellationToken)
}

internal async ValueTask RecoverConsumersAsync(AutorecoveringChannel channelToRecover, IChannel channelToUse,
bool recordedEntitiesSemaphoreHeld = false)
bool recordedEntitiesSemaphoreHeld = false, CancellationToken cancellationToken = default)
{
if (_disposed)
{
Expand All @@ -520,7 +519,8 @@ internal async ValueTask RecoverConsumersAsync(AutorecoveringChannel channelToRe
}
finally
{
_recordedEntitiesSemaphore.Wait();
await _recordedEntitiesSemaphore.WaitAsync(cancellationToken)
.ConfigureAwait(false);
}

string oldTag = consumer.ConsumerTag;
Expand All @@ -540,7 +540,7 @@ internal async ValueTask RecoverConsumersAsync(AutorecoveringChannel channelToRe
}
finally
{
await _recordedEntitiesSemaphore.WaitAsync()
await _recordedEntitiesSemaphore.WaitAsync(cancellationToken)
.ConfigureAwait(false);
}
}
Expand All @@ -558,7 +558,7 @@ await _config.TopologyRecoveryExceptionHandler.ConsumerRecoveryExceptionHandlerA
}
finally
{
await _recordedEntitiesSemaphore.WaitAsync()
await _recordedEntitiesSemaphore.WaitAsync(cancellationToken)
.ConfigureAwait(false);
}
}
Expand Down