Negative or huge Retry-After makes the retry sleep throw IllegalArgumentException

オープン 初心者向け
#239 コメント 0 件 リアクション 0 件 担当者 0 名 GitHub で見る

メンテナーはふだん 3 日以内に返信

まだ誰も着手していません。

評価

難易度
2/5
見積もり時間
1〜3時間
初心者へのやさしさ
72/100
issue の種類
バグ
明瞭さ
明確に書かれている
活発さ
活発
技術スタック
java
領域
backend

調査の方向性

httpclient/src/main/java/com/backblaze/b2/client/webApiHttpClient/B2WebApiHttpClientImpl.java の getRetryAfterSecondsOrNull から始め、次に core/src/main/java/com/backblaze/b2/client/ の B2DefaultRetryPolicy.java と B2Sleeper.sleepSeconds を確認してください。B2Retryer.doRetry がリトライ可能な例外を受け取り、getRetryAfterSecondsOrNull が -1 または 2200000 を返すようにした単体テストで再現させてください。範囲外の Retry-After 値が上限で丸められるか拒否され、スリープで IllegalArgumentException が発生しなくなれば完了です。

索引モデルが issue の本文から書いたものです。

説明

What happens

The Retry-After header is parsed with Integer.parseInt and returned unchanged as the wait time. B2Sleeper.sleepSeconds then computes seconds * 1000 as an int, which is negative for a negative header and overflows for values above about 2.1 million seconds, and Thread.sleep throws an unchecked IllegalArgumentException. The exception escapes the retry loop, although the code comment in B2Retryer says the sleep "won't throw".

Where

httpclient/src/main/java/com/backblaze/b2/client/webApiHttpClient/B2WebApiHttpClientImpl.java:303-314 (getRetryAfterSecondsOrNull), core/src/main/java/com/backblaze/b2/client/B2DefaultRetryPolicy.java:44-52 (returns the server value unchecked), core/src/main/java/com/backblaze/b2/client/B2Sleeper.java:37-38 (seconds * 1000), called from B2Retryer.java (sleeper.sleepSeconds(waitSeconds)).

Why it matters

Impact: Availability (a retryable error turns into an unexpected runtime exception), loud. Severity: High, because it needs a Retry-After value that is negative or over about 2.1 million seconds from the server (unusual, since the HTTP spec allows only non-negative delays), and there is no workaround besides a custom retry policy.

How to check

Found by reading the code, not reproduced. Read the four places above. A unit test could make B2Retryer.doRetry see a retryable exception whose getRetryAfterSecondsOrNull() returns -1 or 2200000 and observe the exception from Thread.sleep. Clamping the value to a sane range in the retry policy or in B2Sleeper would avoid it.

Version

Seen at v6.5.0. Present on the default branch: present.

主要言語
Java
スター
103
フォーク
23
平均マージ
5日 8時間
マージ済み PR(30日)
3

環境構築

このプロジェクトには開発コンテナ、Dockerfile、コントリビューションガイドがありません。まず README を読み、一般的な手順ははじめてのコントリビューションガイドを参照してください。

はじめの一歩

  1. issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
  2. 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
  3. リポジトリをフォークし、ブランチを切って変更します。
  4. issue 番号を参照したプルリクエストを送ります。

Backblaze/b2-sdk-java のほかの issue

Backblaze/b2-sdk-java の issue をすべて見る

似ている issue

Java の issue をもっと見る

新しい issue をメールで受け取る

初心者向けの GitHub issue を短くまとめたダイジェスト。