Commit 304f171
committed
Use Int64.random instead of .randomElement in HTTPConnectionPool.calculateBackoff
Motivation:
On 32-bit systems, using .randomElement on a range larger than what can fit in Int32 causes a crash. After only 26 or 27 retries of a request using HTTPClient, the calculateBackoff method would run into this and crash consistently on an armv7 (32-bit) device.
Modifications:
A one-line fix to opt to using Int64.random on the same jitterRange instead of .randomElement, which works as expected without crashing on 32-bit systems.
Result:
The HTTPClient now works as expected and can perform as many retries as needed without crashing.1 parent 20216df commit 304f171
File tree
1 file changed
+1
-1
lines changed- Sources/AsyncHTTPClient/ConnectionPool/State Machine
1 file changed
+1
-1
lines changedLines changed: 1 addition & 1 deletion
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
61 | 61 | | |
62 | 62 | | |
63 | 63 | | |
64 | | - | |
| 64 | + | |
65 | 65 | | |
66 | 66 | | |
67 | 67 | | |
| |||
0 commit comments