@@ -421,7 +421,6 @@ public ResponseMessage ReceiveMessage(
421
421
catch ( Exception ex )
422
422
{
423
423
helper . FailedReceivingMessage ( ex ) ;
424
- ThrowOperationCanceledExceptionIfRequired ( ex ) ;
425
424
throw ;
426
425
}
427
426
}
@@ -457,7 +456,6 @@ public async Task<ResponseMessage> ReceiveMessageAsync(
457
456
catch ( Exception ex )
458
457
{
459
458
helper . FailedReceivingMessage ( ex ) ;
460
- ThrowOperationCanceledExceptionIfRequired ( ex ) ;
461
459
throw ;
462
460
}
463
461
}
@@ -540,7 +538,6 @@ public void SendMessage(OperationContext operationContext, RequestMessage messag
540
538
catch ( Exception ex )
541
539
{
542
540
helper . FailedSendingMessage ( ex ) ;
543
- ThrowOperationCanceledExceptionIfRequired ( ex ) ;
544
541
throw ;
545
542
}
546
543
}
@@ -577,7 +574,6 @@ public async Task SendMessageAsync(OperationContext operationContext, RequestMes
577
574
catch ( Exception ex )
578
575
{
579
576
helper . FailedSendingMessage ( ex ) ;
580
- ThrowOperationCanceledExceptionIfRequired ( ex ) ;
581
577
throw ;
582
578
}
583
579
}
@@ -687,19 +683,6 @@ ex is OperationCanceledException ||
687
683
return new MongoConnectionException ( _connectionId , message , ex ) ;
688
684
}
689
685
690
- private void ThrowOperationCanceledExceptionIfRequired ( Exception exception )
691
- {
692
- if ( exception is ObjectDisposedException objectDisposedException )
693
- {
694
- // We expect two cases here:
695
- // objectDisposedException.ObjectName == GetType().Name
696
- // objectDisposedException.Message == "The semaphore has been disposed."
697
- // but since the last one is language-specific, the only option we have is avoiding any additional conditions for ObjectDisposedException
698
- // TODO: this logic should be reviewed in the scope of https://jira.mongodb.org/browse/CSHARP-3165
699
- throw new OperationCanceledException ( $ "The { nameof ( BinaryConnection ) } operation has been cancelled.", exception ) ;
700
- }
701
- }
702
-
703
686
// nested classes
704
687
private class OpenConnectionHelper
705
688
{
0 commit comments