-
-
Notifications
You must be signed in to change notification settings - Fork 1.3k
[Bug]: ArgumentOutOfRangeException in BulkheadSemaphoreFactory when passing int.MaxValue for maxQueueingActions #2637
Copy link
Copy link
Description
Describe the bug
Exception is thrown when maxQueueingActions is set to int.MaxValue due to line 10:
Math.Min(maxQueueingActions + maxParallelization, int.MaxValue);Expected behavior
BulkheadSemaphoreFactory should default to int.MaxValue.
Actual behavior
ArgumentOutOfRangeException is thrown because int.MaxValue + any number > 0 results in a negative number.
Steps to reproduce
No response
Exception(s) (if any)
Unhandled exception. System.ArgumentOutOfRangeException: The initialCount argument must be non-negative and less than or equal to the maximumCount. (Parameter 'initialCount') │
Actual value was -2147483639. │
at System.Threading.SemaphoreSlim..ctor(Int32 initialCount, Int32 maxCount) │
at Polly.Bulkhead.BulkheadSemaphoreFactory.CreateBulkheadSemaphores(Int32 maxParallelization, Int32 maxQueueingActions) │
at Polly.Bulkhead.AsyncBulkheadPolicy..ctor(Int32 maxParallelization, Int32 maxQueueingActions, Func`2 onBulkheadRejectedAsync) │
at Polly.Policy.BulkheadAsync(Int32 maxParallelization, Int32 maxQueuingActions, Func`2 onBulkheadRejectedAsync) │
at Polly.Policy.BulkheadAsync(Int32 maxParallelization, Int32 maxQueuingActions)
Polly version
8.6.0
.NET Version
9.0.203
Anything else?
No response
Reactions are currently unavailable