Skip to content

Commit

Permalink
KTOR-5099 Fix memory leak in HttpRequestRetry plugin (#3316)
Browse files Browse the repository at this point in the history
  • Loading branch information
rsinukov authored and marychatte committed Jan 10, 2023
1 parent c6e8173 commit d02c59f
Showing 1 changed file with 5 additions and 2 deletions.
Expand Up @@ -327,8 +327,11 @@ public class HttpRequestRetry internal constructor(configuration: Configuration)

private fun prepareRequest(request: HttpRequestBuilder): HttpRequestBuilder {
val subRequest = HttpRequestBuilder().takeFrom(request)
val subRequestJob = Job(request.executionContext)
subRequest.executionContext = subRequestJob
request.executionContext.invokeOnCompletion { cause ->
val subRequestJob = subRequest.executionContext as CompletableJob
if (cause == null) subRequestJob.complete()
else subRequestJob.completeExceptionally(cause)
}
return subRequest
}

Expand Down

0 comments on commit d02c59f

Please sign in to comment.