Skip to content

Fix: replace hardcoded single retry with exponential backoff retry#26

Open
HashidaTKS wants to merge 1 commit into
masterfrom
fix/retry-logic
Open

Fix: replace hardcoded single retry with exponential backoff retry#26
HashidaTKS wants to merge 1 commit into
masterfrom
fix/retry-logic

Conversation

@HashidaTKS

Copy link
Copy Markdown
Owner

問題点

XmlSerializerWrapper.Serialize() 内のリトライロジックが以下の問題を持っていた:

  • Thread.Sleep(100) という根拠のない固定待機時間
  • 1回のみのリトライで、それ以外の試行回数変更が困難
  • ログが記録されず失敗の把握が不可能
  • catch {} で全例外をキャッチ

改善内容

  • RetryOnIoException ヘルパーメソッドを導入
  • 定数 RetryCount = 3RetryIntervalMs = 200 で設定を一元管理
  • attempt * RetryIntervalMs でインクリメンタルな待機時間を設定(線形バックオフ)
  • catch (IOException ex) when (attempt < RetryCount)IOException のみを対象にリトライ
  • リトライ前に LoggerWrapper.Warn(ex) でログを記録

Test plan

  • IOException が発生した際に最大3回リトライされることを確認
  • リトライ間隔が attempt に応じて増加することを確認
  • 最終リトライでも失敗した場合に例外がスローされることを確認
  • ログにリトライの記録が残ることを確認

🤖 Generated with Claude Code

…koff retry

The previous retry logic used a hardcoded Thread.Sleep(100) with one retry,
which was arbitrary and provided no logging. Replace with a RetryOnIoException
helper that retries up to RetryCount times, applies an incrementally increasing
wait (200ms * attempt), catches only IOException, and logs each failed attempt.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant