File tree Expand file tree Collapse file tree 5 files changed +49
-14
lines changed Expand file tree Collapse file tree 5 files changed +49
-14
lines changed Original file line number Diff line number Diff line change @@ -283,11 +283,17 @@ public async ValueTask DisposeAsync()
283283 await this . AbortAsync ( )
284284 . ConfigureAwait ( false ) ;
285285 }
286-
287- _recordedConsumerTags . Clear ( ) ;
288286 }
289287 finally
290288 {
289+ try
290+ {
291+ _recordedConsumerTags . Clear ( ) ;
292+ }
293+ catch
294+ {
295+ }
296+
291297 _disposed = true ;
292298 }
293299 }
Original file line number Diff line number Diff line change @@ -296,18 +296,24 @@ public async ValueTask DisposeAsync()
296296 {
297297 await _innerConnection . DisposeAsync ( )
298298 . ConfigureAwait ( false ) ;
299-
300- _channels . Clear ( ) ;
301- _recordedEntitiesSemaphore . Dispose ( ) ;
302- _channelsSemaphore . Dispose ( ) ;
303- _recoveryCancellationTokenSource . Dispose ( ) ;
304299 }
305300 catch ( OperationInterruptedException )
306301 {
307302 // ignored, see rabbitmq/rabbitmq-dotnet-client#133
308303 }
309304 finally
310305 {
306+ try
307+ {
308+ _channels . Clear ( ) ;
309+ _recordedEntitiesSemaphore . Dispose ( ) ;
310+ _channelsSemaphore . Dispose ( ) ;
311+ _recoveryCancellationTokenSource . Dispose ( ) ;
312+ }
313+ catch
314+ {
315+ }
316+
311317 _disposed = true ;
312318 }
313319 }
Original file line number Diff line number Diff line change @@ -573,15 +573,23 @@ protected virtual void Dispose(bool disposing)
573573 this . AbortAsync ( ) . GetAwaiter ( ) . GetResult ( ) ;
574574 }
575575
576- _serverOriginatedChannelCloseTcs ? . Task . Wait ( TimeSpan . FromSeconds ( 5 ) ) ;
576+ _serverOriginatedChannelCloseTcs ? . Task . Wait ( InternalConstants . DefaultChannelDisposeTimeout ) ;
577577
578578 ConsumerDispatcher . Dispose ( ) ;
579- _rpcSemaphore . Dispose ( ) ;
580- _confirmSemaphore . Dispose ( ) ;
579+
581580 _outstandingPublisherConfirmationsRateLimiter ? . Dispose ( ) ;
582581 }
583582 finally
584583 {
584+ try
585+ {
586+ _rpcSemaphore . Dispose ( ) ;
587+ _confirmSemaphore . Dispose ( ) ;
588+ }
589+ catch
590+ {
591+ }
592+
585593 _disposed = true ;
586594 }
587595 }
@@ -622,13 +630,11 @@ await this.AbortAsync()
622630
623631 if ( _serverOriginatedChannelCloseTcs is not null )
624632 {
625- await _serverOriginatedChannelCloseTcs . Task . WaitAsync ( TimeSpan . FromSeconds ( 5 ) )
633+ await _serverOriginatedChannelCloseTcs . Task . WaitAsync ( InternalConstants . DefaultChannelDisposeTimeout )
626634 . ConfigureAwait ( false ) ;
627635 }
628636
629637 ConsumerDispatcher . Dispose ( ) ;
630- _rpcSemaphore . Dispose ( ) ;
631- _confirmSemaphore . Dispose ( ) ;
632638
633639 if ( _outstandingPublisherConfirmationsRateLimiter is not null )
634640 {
@@ -638,6 +644,15 @@ await _outstandingPublisherConfirmationsRateLimiter.DisposeAsync()
638644 }
639645 finally
640646 {
647+ try
648+ {
649+ _rpcSemaphore . Dispose ( ) ;
650+ _confirmSemaphore . Dispose ( ) ;
651+ }
652+ catch
653+ {
654+ }
655+
641656 _disposed = true ;
642657 }
643658 }
Original file line number Diff line number Diff line change @@ -550,7 +550,14 @@ await _channel0.DisposeAsync()
550550 }
551551 finally
552552 {
553- _mainLoopCts . Dispose ( ) ;
553+ try
554+ {
555+ _mainLoopCts . Dispose ( ) ;
556+ }
557+ catch
558+ {
559+ }
560+
554561 _disposed = true ;
555562 }
556563 }
Original file line number Diff line number Diff line change @@ -37,6 +37,7 @@ internal static class InternalConstants
3737 {
3838 internal static readonly TimeSpan DefaultConnectionAbortTimeout = TimeSpan . FromSeconds ( 5 ) ;
3939 internal static readonly TimeSpan DefaultConnectionCloseTimeout = TimeSpan . FromSeconds ( 30 ) ;
40+ internal static readonly TimeSpan DefaultChannelDisposeTimeout = TimeSpan . FromSeconds ( 5 ) ;
4041
4142 /// <summary>
4243 /// Largest message size, in bytes, allowed in RabbitMQ.
You can’t perform that action at this time.
0 commit comments