1
0
mirror of synced 2024-11-24 11:43:12 +01:00

Ignore OperationCanceledException as well when shutting down

This commit is contained in:
Mark van Renswoude 2021-01-18 14:17:07 +01:00
parent 2431929ca3
commit 0b7c84a119
3 changed files with 5 additions and 6 deletions

View File

@ -134,7 +134,7 @@ namespace Tapeti.Connection
private void HandleException(ExceptionStrategyContext exceptionContext)
{
if (cancellationToken.IsCancellationRequested && IsTaskCanceledException(exceptionContext.Exception))
if (cancellationToken.IsCancellationRequested && IgnoreExceptionDuringShutdown(exceptionContext.Exception))
{
// The service is most likely stopping, and the connection is gone anyways.
exceptionContext.SetConsumeResult(ConsumeResult.Requeue);
@ -156,18 +156,19 @@ namespace Tapeti.Connection
}
private static bool IsTaskCanceledException(Exception e)
private static bool IgnoreExceptionDuringShutdown(Exception e)
{
switch (e)
{
case AggregateException aggregateException:
return aggregateException.InnerExceptions.Any(IsTaskCanceledException);
return aggregateException.InnerExceptions.Any(IgnoreExceptionDuringShutdown);
case TaskCanceledException _:
case OperationCanceledException _: // thrown by CancellationTokenSource.ThrowIfCancellationRequested
return true;
default:
return e.InnerException != null && IsTaskCanceledException(e.InnerException);
return e.InnerException != null && IgnoreExceptionDuringShutdown(e.InnerException);
}
}

View File

@ -155,7 +155,6 @@ namespace Tapeti.Default
public bool HasHandler => Handler != null;
/// <inheritdoc />
public ControllerBindingResult(ParameterInfo info)
{
Info = info;

View File

@ -99,7 +99,6 @@ namespace Tapeti.Default
public MethodInfo Method => bindingInfo.Method;
/// <inheritdoc />
public ControllerMethodBinding(IDependencyResolver dependencyResolver, BindingInfo bindingInfo)
{
this.dependencyResolver = dependencyResolver;