Description
Hello!
I found a few bugs in the class System.Threading.RateLimiting.ChainedRateLimiter
- Implemenration of IdleDuration
If at least one IdleDuration object is non-null, a non-null value will be returned always. This will clear the entire chain in DefaultPartitionedRateLimiter.Heartbeat. Even if there are active limiters with nullable idleDuration.
public override TimeSpan? IdleDuration
{
get
{
ThrowIfDisposed();
TimeSpan? lowestIdleDuration = null;
foreach (RateLimiter limiter in _limiters)
{
if (limiter.IdleDuration is { } idleDuration)
{
if (lowestIdleDuration is null || idleDuration < lowestIdleDuration)
{
lowestIdleDuration = idleDuration;
}
}
}
return lowestIdleDuration;
}
}
- ChainedRateLimiter not implements ReplenishingRateLimiter
Because of this, the TryReplenish method will not be called for the chain of child objects.
See DefaultPartitionedRateLimiter.Heartbeat
Reproduction Steps
I tried to use this class and caught the described bugs.
Expected behavior
Code without bugs
Actual behavior
Code without bugs
Regression?
No response
Known Workarounds
No response
Configuration
No response
Other information
No response
Description
Hello!
I found a few bugs in the class System.Threading.RateLimiting.ChainedRateLimiter
If at least one IdleDuration object is non-null, a non-null value will be returned always. This will clear the entire chain in DefaultPartitionedRateLimiter.Heartbeat. Even if there are active limiters with nullable idleDuration.
Because of this, the TryReplenish method will not be called for the chain of child objects.
See DefaultPartitionedRateLimiter.Heartbeat
Reproduction Steps
I tried to use this class and caught the described bugs.
Expected behavior
Code without bugs
Actual behavior
Code without bugs
Regression?
No response
Known Workarounds
No response
Configuration
No response
Other information
No response