Improve handling of Jira's retry-after handling
As reported in #1805, while 3.6.0 brought a beneficial change in evaluating Jira's retry-after header, in some scenarios it actually degraded the success rate of requests when hitting rate-limits due to two issues:
- Jira intends the retry-after header to be a minimum backoff but the code treats it as a maximum backoff, and
- Jira sometimes sends a retry-after value of 0 seconds which the existing code implicitly treated as a failed request.
To address this, this PR changes the back-off behaviour to treat the retry-after time as a minimum backoff, at least as long as our maximum back-off time does allow this, and clips the retry-after header, if specified, to a minimum of one second.
I have extended the existing tests for the retry logic to assert this behaviour. If you would prefer a separate set of tests or see other changes to the approach, let me know and I'll adjust the PR.
The cloud tests are failing in set-up and this seems to be a wider issue unrelated to my changes as I am also seeing that on other PRs. Happy to rebase once that is fixed on main.
Thanks for the excellent PR and sorry for the delay in getting in merged and released!