This repository was archived by the owner on Feb 11, 2026. It is now read-only.
fix:在某些情况下httpResponse没有关闭(in some special case,httpResponse not close)#586
Open
tangwc wants to merge 2 commits into
Open
fix:在某些情况下httpResponse没有关闭(in some special case,httpResponse not close)#586tangwc wants to merge 2 commits into
tangwc wants to merge 2 commits into
Conversation
DoActionWithSigner,if AutoRetry may cause httpResponse not close. the httpResponse close logic is outside the for loop in responses.Unmarshal function. if AutoRetry open and response no err but statusCode wrong.in this cause httpResponse not close. 1、if client.buildRequestWithSigner has err,it will return then cause the problem 2、if continue,httpResponse will redefined then cause the problem so add defer httpResponse.Body.Close() in for loop to solve it. DoActionWithSigner,自动重试时有可能造成没有关闭链接的问题。 当前逻辑,代码仅在for循环之外的responses.Unmarshal中处理了httpResponse的close。但是在for循环中的最后一个逻辑-自动重试会有问题。 如果AutoRetry开启,返回正常,但是返回的statusCode大于设定值,会进入自动重试逻辑。这个重试逻辑里有两种可能。 1、client.buildRequestWithSigner时报错,会return掉,导致httpResponse没有关闭。 2、continue时,httpResponse会重新赋值,导致老的httpResponse没有关闭。
|
tangweichen seems not to be a GitHub user. You need a GitHub account to be able to sign the CLA. If you have already a GitHub account, please add the email address used for this commit to your account. You have signed the CLA already but the status is still pending? Let us recheck it. |
Contributor
|
非常感谢提供pr,确实有这个问题,代码看起来也没问题。我们需要再加个测试验证下。 |
yndu13
reviewed
Jun 8, 2023
| return | ||
| } | ||
| } | ||
| defer httpResponse.Body.Close() |
Contributor
There was a problem hiding this comment.
当出现服务不存在等报错时,这里会有中断,辛苦加个判断:
if httpResponse != nil && httpResponse.Body != nil {
defer httpResponse.Body.Close()
}
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to subscribe to this conversation on GitHub.
Already have an account?
Sign in.
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
DoActionWithSigner,if AutoRetry may cause httpResponse not close. the httpResponse close logic is outside the for loop in responses.Unmarshal function. if AutoRetry open and response no err but statusCode wrong.in this cause httpResponse not close. 1、if client.buildRequestWithSigner has err,it will return then cause the problem 2、if continue,httpResponse will redefined then cause the problem so add defer httpResponse.Body.Close() in for loop to solve it.
DoActionWithSigner,自动重试时有可能造成没有关闭链接的问题。
当前逻辑,代码仅在for循环之外的responses.Unmarshal中处理了httpResponse的close。但是在for循环中的最后一个逻辑-自动重试会有问题。 如果AutoRetry开启,返回正常,但是返回的statusCode大于设定值,会进入自动重试逻辑。这个重试逻辑里有两种可能。 1、client.buildRequestWithSigner时报错,会return掉,导致httpResponse没有关闭。 2、continue时,httpResponse会重新赋值,导致老的httpResponse没有关闭。