Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix:在某些情况下httpResponse没有关闭(in some special case,httpResponse not close) #586

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 7 additions & 4 deletions sdk/client.go
Original file line number Diff line number Diff line change
Expand Up @@ -633,8 +633,8 @@ func (client *Client) DoActionWithSigner(request requests.AcsRequest, response r
span = tracer.StartSpan(
httpRequest.URL.RequestURI(),
opentracing.ChildOf(rootCtx),
opentracing.Tag{string(ext.Component), "aliyunApi"},
opentracing.Tag{"actionName", request.GetActionName()})
opentracing.Tag{Key: string(ext.Component), Value: "aliyunApi"},
opentracing.Tag{Key: "actionName", Value: request.GetActionName()})

defer span.Finish()
tracer.Inject(
Expand Down Expand Up @@ -692,6 +692,7 @@ func (client *Client) DoActionWithSigner(request requests.AcsRequest, response r
return
}
}
defer httpResponse.Body.Close()
Copy link
Contributor

@yndu13 yndu13 Jun 8, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

当出现服务不存在等报错时,这里会有中断,辛苦加个判断:
if httpResponse != nil && httpResponse.Body != nil {
defer httpResponse.Body.Close()
}

if isCertificateError(err) {
return
}
Expand Down Expand Up @@ -771,11 +772,13 @@ func isServerError(httpResponse *http.Response) bool {
return httpResponse.StatusCode >= http.StatusInternalServerError
}

/**
/*
*
only block when any one of the following occurs:
1. the asyncTaskQueue is full, increase the queue size to avoid this
2. Shutdown() in progressing, the client is being closed
**/
*
*/
func (client *Client) AddAsyncTask(task func()) (err error) {
if client.asyncTaskQueue != nil {
if client.isOpenAsync {
Expand Down