Skip to content

Add test for AdaptiveRetry free retries when shouldPayFailureCost is false#449

Closed
adamw wants to merge 1 commit into
masterfrom
fix-adaptive-retry-left-free-retry
Closed

Add test for AdaptiveRetry free retries when shouldPayFailureCost is false#449
adamw wants to merge 1 commit into
masterfrom
fix-adaptive-retry-left-free-retry

Conversation

@adamw
Copy link
Copy Markdown
Member

@adamw adamw commented May 29, 2026

Reproduces issue #442: AdaptiveRetry incorrectly stops retrying on Left when shouldPayFailureCost returns false.

The test verifies that when shouldPayFailureCost is false, retry attempts should not consume from the token bucket. Currently, all 6 attempts (1 initial + 5 retries) are expected to succeed despite a token bucket with only 2 tokens, since no cost should be paid.

The fix implementation will follow.

Closes #442.

@adamw
Copy link
Copy Markdown
Member Author

adamw commented May 29, 2026

Found it. Here's the relevant excerpt:


Test failure in AdaptiveRetryTest (Java 24 run):

AdaptiveRetryTest:
AdaptiveRetry
- should not pay failureCost if result E is going to be retried and shouldPayFailureCost returns false *** FAILED ***
  1 was not equal to 6 (AdaptiveRetryTest.scala:30)

The newly added failing test (should not pay failureCost if result E is going to be retried and shouldPayFailureCost returns false) is failing as expected — it was added to document the bug, not to pass. The assertion at line 30 gets 1 but expects 6, confirming the bug: AdaptiveRetry is stopping on a Left result even when shouldPayFailureCost returns false (i.e., the retry budget is being incorrectly debited on Left values that should not incur a failure cost).

@adamw adamw closed this May 29, 2026
@adamw adamw deleted the fix-adaptive-retry-left-free-retry branch May 29, 2026 19:22
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.

ox AdaptiveRetry stops retrying on Left when shouldPayFailureCost is false

1 participant