diff --git a/sdk/servicebus/Microsoft.Azure.ServiceBus/src/MessageReceivePump.cs b/sdk/servicebus/Microsoft.Azure.ServiceBus/src/MessageReceivePump.cs index 463af1e595818..349e3cb3e8c1c 100644 --- a/sdk/servicebus/Microsoft.Azure.ServiceBus/src/MessageReceivePump.cs +++ b/sdk/servicebus/Microsoft.Azure.ServiceBus/src/MessageReceivePump.cs @@ -84,14 +84,18 @@ async Task MessagePumpTaskAsync() }); } } + catch (OperationCanceledException) when (pumpCancellationToken.IsCancellationRequested) + { + // Ignore as we are stopping the pump + } + catch (ObjectDisposedException) when (pumpCancellationToken.IsCancellationRequested) + { + // Ignore as we are stopping the pump + } catch (Exception exception) { - // Not reporting an ObjectDisposedException as we're stopping the pump - if (!(exception is ObjectDisposedException && this.pumpCancellationToken.IsCancellationRequested)) - { - MessagingEventSource.Log.MessageReceivePumpTaskException(this.messageReceiver.ClientId, string.Empty, exception); - await this.RaiseExceptionReceived(exception, ExceptionReceivedEventArgsAction.Receive).ConfigureAwait(false); - } + MessagingEventSource.Log.MessageReceivePumpTaskException(this.messageReceiver.ClientId, string.Empty, exception); + await this.RaiseExceptionReceived(exception, ExceptionReceivedEventArgsAction.Receive).ConfigureAwait(false); } finally {