@@ -4,7 +4,6 @@ namespace Polly.Bulkhead;
4
4
/// <summary>
5
5
/// A bulkhead-isolation policy which can be applied to delegates.
6
6
/// </summary>
7
- #pragma warning disable CA1062 // Validate arguments of public methods
8
7
public class BulkheadPolicy : Policy , IBulkheadPolicy
9
8
{
10
9
private readonly SemaphoreSlim _maxParallelizationSemaphore ;
@@ -25,8 +24,21 @@ internal BulkheadPolicy(
25
24
26
25
/// <inheritdoc/>
27
26
[ DebuggerStepThrough ]
28
- protected override TResult Implementation < TResult > ( Func < Context , CancellationToken , TResult > action , Context context , CancellationToken cancellationToken ) =>
29
- BulkheadEngine . Implementation ( action , context , _onBulkheadRejected , _maxParallelizationSemaphore , _maxQueuedActionsSemaphore , cancellationToken ) ;
27
+ protected override TResult Implementation < TResult > ( Func < Context , CancellationToken , TResult > action , Context context , CancellationToken cancellationToken )
28
+ {
29
+ if ( action is null )
30
+ {
31
+ throw new ArgumentNullException ( nameof ( action ) ) ;
32
+ }
33
+
34
+ return BulkheadEngine . Implementation (
35
+ action ,
36
+ context ,
37
+ _onBulkheadRejected ,
38
+ _maxParallelizationSemaphore ,
39
+ _maxQueuedActionsSemaphore ,
40
+ cancellationToken ) ;
41
+ }
30
42
31
43
/// <summary>
32
44
/// Gets the number of slots currently available for executing actions through the bulkhead.
@@ -73,8 +85,20 @@ internal BulkheadPolicy(
73
85
74
86
/// <inheritdoc/>
75
87
[ DebuggerStepThrough ]
76
- protected override TResult Implementation ( Func < Context , CancellationToken , TResult > action , Context context , CancellationToken cancellationToken ) =>
77
- BulkheadEngine . Implementation ( action , context , _onBulkheadRejected , _maxParallelizationSemaphore , _maxQueuedActionsSemaphore , cancellationToken ) ;
88
+ protected override TResult Implementation ( Func < Context , CancellationToken , TResult > action , Context context , CancellationToken cancellationToken )
89
+ {
90
+ if ( action is null )
91
+ {
92
+ throw new ArgumentNullException ( nameof ( action ) ) ;
93
+ }
94
+
95
+ return BulkheadEngine . Implementation (
96
+ action ,
97
+ context ,
98
+ _onBulkheadRejected ,
99
+ _maxParallelizationSemaphore ,
100
+ _maxQueuedActionsSemaphore , cancellationToken ) ;
101
+ }
78
102
79
103
/// <summary>
80
104
/// Gets the number of slots currently available for executing actions through the bulkhead.
0 commit comments