Commit 4404a7f
committed
Fix panic in shouldRetry type assertion and remove deprecated rand.Seed
- Use comma-ok idiom in shouldRetry to handle non-*Err error types safely
- Remove deprecated rand.Seed call that was re-seeding on every backoff
- Add test coverage for shouldRetry with various error types
The shouldRetry function previously used a direct type assertion
that would panic if passed an error not of type *Err. While this
function is internal and typically receives *Err values, the type
assertion should be safe to handle unexpected inputs.
The rand.Seed call has been deprecated since Go 1.20 as the global
random number generator is now automatically seeded. Additionally,
calling Seed on every retry attempt was wasteful.1 parent 3df8fa8 commit 4404a7f
2 files changed
Lines changed: 19 additions & 3 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
77 | 77 | | |
78 | 78 | | |
79 | 79 | | |
80 | | - | |
81 | 80 | | |
82 | 81 | | |
83 | 82 | | |
| |||
233 | 232 | | |
234 | 233 | | |
235 | 234 | | |
236 | | - | |
237 | | - | |
| 235 | + | |
| 236 | + | |
238 | 237 | | |
239 | 238 | | |
240 | 239 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
127 | 127 | | |
128 | 128 | | |
129 | 129 | | |
| 130 | + | |
| 131 | + | |
| 132 | + | |
| 133 | + | |
| 134 | + | |
| 135 | + | |
| 136 | + | |
| 137 | + | |
| 138 | + | |
| 139 | + | |
| 140 | + | |
| 141 | + | |
| 142 | + | |
| 143 | + | |
| 144 | + | |
| 145 | + | |
| 146 | + | |
130 | 147 | | |
131 | 148 | | |
132 | 149 | | |
| |||
0 commit comments