Skip to content

Commit

Permalink
KTOR-5099 Fix memory leak in HttpRequestRetry plugin (ktorio#3316)
Browse files Browse the repository at this point in the history
  • Loading branch information
rsinukov authored and Rattenkrieg committed Jan 5, 2023
1 parent f2db562 commit c2f49e8
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 c2f49e8

Please sign in to comment.