Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

concurrent-api: fix IllegalArgumentExcetion for zero jitter in RetryStrategies #2777

Conversation

bryce-anderson
Copy link
Contributor

@bryce-anderson bryce-anderson commented Dec 8, 2023

Motivation:

If you pass in a jitter of 0 for the retry strategies with delta delay you'll get an IllegalArgumentException thrown by the Random.nextLong(lower, upper) method because the lower and upper are the same value. This is because the upper bound argument is non-inclusive.

Modifications:

Add 1 to each call to extend the range by 1 nanosecond and make the full delay range selectable. We also do this in the case of the *FullJitter methods to make the full delay an option instead of being limited to delay - 1ns.

Result:

Less illegal argument exceptions and (technically, although admittedly not practically important) correct delay ranges.

…trategies

Motivation:

If you pass in a jitter of 0 for the retry strategies you'll get
an IllegalArgumentException thrown by the `Random.nextLong(lower, upper)`
method because the lower and upper are the same value. This is because
the upper bound argument is non-inclusive.

Modifications:

Add 1 to each call to extend the range by 1 nanosecond and make the full
delay range selectable.

Result:

What is the result of this change?
@bryce-anderson bryce-anderson merged commit cf40cb3 into apple:main Dec 8, 2023
15 checks passed
@bryce-anderson bryce-anderson deleted the bl_anderson/retryStrategy_zero_jitter_bug branch December 8, 2023 21:25
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants