Skip to content

Commit 41e4d66

Browse files
committed
Pass through reason only
1 parent 645d769 commit 41e4d66

File tree

6 files changed

+17
-20
lines changed

6 files changed

+17
-20
lines changed

projects/RabbitMQ.Client/IChannel.cs

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -262,10 +262,8 @@ Task CloseAsync(ushort replyCode, string replyText, bool abort,
262262
/// </summary>
263263
/// <param name="reason">The <see cref="ShutdownEventArgs"/> instance containing the close data.</param>
264264
/// <param name="abort">Whether or not the close is an abort (ignoring certain exceptions).</param>
265-
/// <param name="cancellationToken">CancellationToken for this operation.</param>
266265
/// <returns></returns>
267-
Task CloseAsync(ShutdownEventArgs reason, bool abort,
268-
CancellationToken cancellationToken = default);
266+
Task CloseAsync(ShutdownEventArgs reason, bool abort);
269267

270268
/// <summary>Asynchronously declare an exchange.</summary>
271269
/// <param name="exchange">The name of the exchange.</param>

projects/RabbitMQ.Client/Impl/AutorecoveringChannel.cs

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -234,13 +234,12 @@ await _connection.DeleteRecordedChannelAsync(this,
234234
}
235235
}
236236

237-
public async Task CloseAsync(ShutdownEventArgs args, bool abort,
238-
CancellationToken cancellationToken)
237+
public async Task CloseAsync(ShutdownEventArgs args, bool abort)
239238
{
240239
ThrowIfDisposed();
241240
try
242241
{
243-
await _innerChannel.CloseAsync(args, abort, cancellationToken)
242+
await _innerChannel.CloseAsync(args, abort)
244243
.ConfigureAwait(false);
245244
}
246245
finally

projects/RabbitMQ.Client/Impl/Channel.cs

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -202,12 +202,12 @@ public Task CloseAsync(ushort replyCode, string replyText, bool abort,
202202
CancellationToken cancellationToken)
203203
{
204204
var args = new ShutdownEventArgs(ShutdownInitiator.Application, replyCode, replyText, cancellationToken: cancellationToken);
205-
return CloseAsync(args, abort, cancellationToken);
205+
return CloseAsync(args, abort);
206206
}
207207

208-
public async Task CloseAsync(ShutdownEventArgs args, bool abort,
209-
CancellationToken cancellationToken)
208+
public async Task CloseAsync(ShutdownEventArgs args, bool abort)
210209
{
210+
CancellationToken cancellationToken = args.CancellationToken;
211211
CancellationToken argCancellationToken = cancellationToken;
212212
if (IsOpen)
213213
{
@@ -862,7 +862,7 @@ protected async Task<bool> HandleConnectionCloseAsync(IncomingCommand cmd, Cance
862862
await ModelSendAsync(in replyMethod, cancellationToken)
863863
.ConfigureAwait(false);
864864

865-
await Session.Connection.ClosedViaPeerAsync(reason, cancellationToken)
865+
await Session.Connection.ClosedViaPeerAsync(reason)
866866
.ConfigureAwait(false);
867867

868868
SetCloseReason(Session.Connection.CloseReason!);
@@ -897,8 +897,7 @@ protected async Task<bool> HandleConnectionStartAsync(IncomingCommand cmd, Cance
897897
{
898898
var reason = new ShutdownEventArgs(ShutdownInitiator.Library, Constants.CommandInvalid, "Unexpected Connection.Start", cancellationToken: cancellationToken);
899899
await Session.Connection.CloseAsync(reason, false,
900-
InternalConstants.DefaultConnectionCloseTimeout,
901-
cancellationToken)
900+
InternalConstants.DefaultConnectionCloseTimeout)
902901
.ConfigureAwait(false);
903902
}
904903
else

projects/RabbitMQ.Client/Impl/Connection.cs

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -256,8 +256,7 @@ await _channel0.ConnectionOpenAsync(_config.VirtualHost, cancellationToken)
256256
{
257257
var ea = new ShutdownEventArgs(ShutdownInitiator.Library, Constants.InternalError, "FailedOpen", cancellationToken: cancellationToken);
258258
await CloseAsync(ea, true,
259-
InternalConstants.DefaultConnectionAbortTimeout,
260-
cancellationToken).ConfigureAwait(false);
259+
InternalConstants.DefaultConnectionAbortTimeout).ConfigureAwait(false);
261260
}
262261
catch { }
263262

@@ -300,7 +299,7 @@ public Task CloseAsync(ushort reasonCode, string reasonText, TimeSpan timeout, b
300299
CancellationToken cancellationToken = default)
301300
{
302301
var reason = new ShutdownEventArgs(ShutdownInitiator.Application, reasonCode, reasonText, cancellationToken: cancellationToken);
303-
return CloseAsync(reason, abort, timeout, cancellationToken);
302+
return CloseAsync(reason, abort, timeout);
304303
}
305304

306305
///<summary>Asychronously try to close connection in a graceful way</summary>
@@ -318,8 +317,9 @@ public Task CloseAsync(ushort reasonCode, string reasonText, TimeSpan timeout, b
318317
///to complete.
319318
///</para>
320319
///</remarks>
321-
internal async Task CloseAsync(ShutdownEventArgs reason, bool abort, TimeSpan timeout, CancellationToken cancellationToken)
320+
internal async Task CloseAsync(ShutdownEventArgs reason, bool abort, TimeSpan timeout)
322321
{
322+
CancellationToken cancellationToken = reason.CancellationToken;
323323
CancellationToken argCancellationToken = cancellationToken;
324324

325325
if (abort && timeout < InternalConstants.DefaultConnectionAbortTimeout)
@@ -435,8 +435,9 @@ await _frameHandler.CloseAsync(cts.Token)
435435
argCancellationToken.ThrowIfCancellationRequested();
436436
}
437437

438-
internal async Task ClosedViaPeerAsync(ShutdownEventArgs reason, CancellationToken cancellationToken)
438+
internal async Task ClosedViaPeerAsync(ShutdownEventArgs reason)
439439
{
440+
CancellationToken cancellationToken = reason.CancellationToken;
440441
if (false == SetCloseReason(reason))
441442
{
442443
if (_closed)

projects/RabbitMQ.Client/PublicAPI.Shipped.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -876,7 +876,7 @@ RabbitMQ.Client.Exceptions.AlreadyClosedException.AlreadyClosedException(RabbitM
876876
RabbitMQ.Client.Exceptions.OperationInterruptedException.ShutdownReason.get -> RabbitMQ.Client.Events.ShutdownEventArgs?
877877
RabbitMQ.Client.IAsyncBasicConsumer.HandleChannelShutdownAsync(object! channel, RabbitMQ.Client.Events.ShutdownEventArgs! reason) -> System.Threading.Tasks.Task!
878878
RabbitMQ.Client.IChannel.ChannelShutdownAsync -> RabbitMQ.Client.Events.AsyncEventHandler<RabbitMQ.Client.Events.ShutdownEventArgs!>!
879-
RabbitMQ.Client.IChannel.CloseAsync(RabbitMQ.Client.Events.ShutdownEventArgs! reason, bool abort, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) -> System.Threading.Tasks.Task!
879+
RabbitMQ.Client.IChannel.CloseAsync(RabbitMQ.Client.Events.ShutdownEventArgs! reason, bool abort) -> System.Threading.Tasks.Task!
880880
RabbitMQ.Client.IChannel.CloseReason.get -> RabbitMQ.Client.Events.ShutdownEventArgs?
881881
RabbitMQ.Client.IConnection.CloseReason.get -> RabbitMQ.Client.Events.ShutdownEventArgs?
882882
RabbitMQ.Client.IConnection.ConnectionShutdownAsync -> RabbitMQ.Client.Events.AsyncEventHandler<RabbitMQ.Client.Events.ShutdownEventArgs!>!

projects/Test/Integration/TestAsyncConsumer.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -514,7 +514,7 @@ await _channel.BasicConsumeAsync(queue: queueName, autoAck: false,
514514
Assert.True(await publishSyncSource.Task);
515515
Assert.Equal(messageCount, messagesReceived);
516516
await _channel.QueueDeleteAsync(queue: queueName);
517-
await _channel.CloseAsync(_closeArgs, false, CancellationToken.None);
517+
await _channel.CloseAsync(_closeArgs, false);
518518
}
519519

520520
[Fact]
@@ -591,7 +591,7 @@ await _channel.BasicConsumeAsync(queue: queueName, autoAck: false,
591591
Assert.Equal((uint)0, consumerCount);
592592
}
593593

594-
await _channel.CloseAsync(_closeArgs, false, CancellationToken.None);
594+
await _channel.CloseAsync(_closeArgs, false);
595595
}
596596

597597
[Fact]

0 commit comments

Comments
 (0)