-
Notifications
You must be signed in to change notification settings - Fork 1.5k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
finagle-core: ExponentialJitteredBackoff random zero bugfix
**Problem:** `ExponentialJitteredBackoff.next` throws an exception occasionally. ``` java.lang.IllegalArgumentException: at java.base/java.util.concurrent.ThreadLocalRandom.nextLong(ThreadLocalRandom.java:361) at com.twitter.finagle.util.Rng$$anon$2.nextLong(Rng.scala:71) ERR at com.twitter.finagle.Backoff$ExponentialJittered.next(Backoff.scala:331) ``` **Bug:** `Rng.nextLong(n)` generates a number from 0 (inclusive) to n (exclusive). When it generates 0 as random number. The next occurrence of backoff.next would try fetching `Rng.nextLong(0)` which is illegal argument. **Fix:** Add 1 to the generated random, so that `Rng.nextLong(_)` can accept the number. Since the random generated is exclusive on the `n` provided, this doesn't cause overflow as well. JIRA Issues: STOR-8734 Differential Revision: https://phabricator.twitter.biz/D1178528
- Loading branch information
Shashikanth Reddy Potu
authored and
jenkins
committed
Nov 4, 2024
1 parent
df4c740
commit 05f5618
Showing
3 changed files
with
25 additions
and
7 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters