KTOR-9211 Fix SendCountExceedException when max retries is lesser tha…#5331
KTOR-9211 Fix SendCountExceedException when max retries is lesser tha…#5331
Conversation
WalkthroughHttpSend max-send calculation now derives maxSendCount from a per-request MaxRetries attribute when larger than the plugin default (with Int.MAX_VALUE guard); DefaultSender uses maxSendCount. Two tests added to verify interactions between maxRetries and maxSendCount. Changes
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~20 minutes Possibly related PRs
Suggested reviewers
🚥 Pre-merge checks | ✅ 1 | ❌ 2❌ Failed checks (2 warnings)
✅ Passed checks (1 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing touches
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
There was a problem hiding this comment.
Actionable comments posted: 1
🤖 Fix all issues with AI agents
In
`@ktor-client/ktor-client-tests/common/test/io/ktor/client/tests/HttpRequestRetryTest.kt`:
- Around line 551-573: Rename the test function
testMaxSendCountGreaterThanMaxRetries to follow the DescribeWhatIsBeingTested
pattern (for example maxSendCountGreaterThanMaxRetriesAllowsRedirect) while
keeping the `@Test` annotation and the same body; update any references if the
test name is used elsewhere (e.g., test discovery or logging) so the test still
runs and clearly describes the behavior being verified in
HttpRequestRetryTest.kt.
| @Test | ||
| fun testMaxSendCountGreaterThanMaxRetries() = testWithEngine(MockEngine) { | ||
| config { | ||
| engine { | ||
| addHandler { request -> | ||
| if (request.url.toString().endsWith("/ok")) { | ||
| respondOk() | ||
| } else { | ||
| respondRedirect("/ok") | ||
| } | ||
| } | ||
| } | ||
|
|
||
| install(HttpRequestRetry) { | ||
| retryOnServerErrors(maxRetries = 0) | ||
| delayMillis { 0L } | ||
| } | ||
| } | ||
|
|
||
| test { client -> | ||
| assertEquals(HttpStatusCode.OK, client.get("/").status) | ||
| } | ||
| } |
There was a problem hiding this comment.
Rename test to follow required naming pattern.
Please use the DescribeWhatIsBeingTested format (per test guidelines). As per coding guidelines, consider renaming to something like maxSendCountGreaterThanMaxRetriesAllowsRedirect.
🔧 Suggested rename
- fun testMaxSendCountGreaterThanMaxRetries() = testWithEngine(MockEngine) {
+ fun maxSendCountGreaterThanMaxRetriesAllowsRedirect() = testWithEngine(MockEngine) {🤖 Prompt for AI Agents
In
`@ktor-client/ktor-client-tests/common/test/io/ktor/client/tests/HttpRequestRetryTest.kt`
around lines 551 - 573, Rename the test function
testMaxSendCountGreaterThanMaxRetries to follow the DescribeWhatIsBeingTested
pattern (for example maxSendCountGreaterThanMaxRetriesAllowsRedirect) while
keeping the `@Test` annotation and the same body; update any references if the
test name is used elsewhere (e.g., test discovery or logging) so the test still
runs and clearly describes the behavior being verified in
HttpRequestRetryTest.kt.
https://youtrack.jetbrains.com/issue/KTOR-9211