Ignore OperationCanceledException as well when shutting down
This commit is contained in:
parent
2431929ca3
commit
0b7c84a119
@ -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);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -155,7 +155,6 @@ namespace Tapeti.Default
|
||||
public bool HasHandler => Handler != null;
|
||||
|
||||
|
||||
/// <inheritdoc />
|
||||
public ControllerBindingResult(ParameterInfo info)
|
||||
{
|
||||
Info = info;
|
||||
|
@ -99,7 +99,6 @@ namespace Tapeti.Default
|
||||
public MethodInfo Method => bindingInfo.Method;
|
||||
|
||||
|
||||
/// <inheritdoc />
|
||||
public ControllerMethodBinding(IDependencyResolver dependencyResolver, BindingInfo bindingInfo)
|
||||
{
|
||||
this.dependencyResolver = dependencyResolver;
|
||||
|
Loading…
Reference in New Issue
Block a user