Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion src/Polly.Core/Retry/RetryHelper.cs
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ internal static TimeSpan ApplyJitter(TimeSpan delay, Func<double> randomizer)

return TimeSpan.FromMilliseconds(newDelay);
}
#pragma warning disable IDE0047 // Remove unnecessary parentheses which offer less mental gymnastics
#pragma warning restore IDE0047 // Remove unnecessary parentheses which offer less mental gymnastics

/// <summary>
/// Generates sleep durations in an exponentially backing-off, jittered manner, making sure to mitigate any correlations.
Expand Down
10 changes: 5 additions & 5 deletions test/Polly.Core.Tests/Retry/RetryHelperTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -267,13 +267,13 @@ public void ExponentialWithJitter_EnsureRandomness()
[FsCheck.Xunit.Property(Arbitrary = [typeof(Arbitraries)], MaxTest = 10_000)]
public void ApplyJitter_Meets_Specification(TimeSpan value)
{
var delta = value / 2;
var delta = value / 4;
var floor = value - delta;
var ceiling = value + delta;

var actual = RetryHelper.ApplyJitter(value, RandomUtil.NextDouble);

actual.ShouldBeGreaterThan(floor);
actual.ShouldBeGreaterThanOrEqualTo(floor);
actual.ShouldBeLessThanOrEqualTo(ceiling);
}

Expand All @@ -283,13 +283,13 @@ public void DecorrelatedJitterBackoffV2_Meets_Specification(TimeSpan value, int
var rawCeiling = value.Ticks * Math.Pow(2, attempt) * 4;
var clamped = (long)Math.Clamp(rawCeiling, value.Ticks, TimeSpan.MaxValue.Ticks);

var floor = value;
var floor = TimeSpan.Zero;
var ceiling = TimeSpan.FromTicks(clamped - 1);

var _ = default(double);
var actual = RetryHelper.DecorrelatedJitterBackoffV2(attempt, value, ref _, RandomUtil.NextDouble);

actual.ShouldBeGreaterThan(floor);
actual.ShouldBeGreaterThanOrEqualTo(floor);
actual.ShouldBeLessThanOrEqualTo(ceiling);
}
#endif
Expand Down Expand Up @@ -318,7 +318,7 @@ public static class Arbitraries
public static Arbitrary<int> PositiveInteger()
{
var minimum = 1;
var maximum = 2056;
var maximum = 2048;
var generator = Gen.Choose(minimum, maximum);

return Arb.From(generator);
Expand Down
Loading