Skip to content

Commit 3d19639

Browse files
committed
fix: close http resp for fdb vpc address check
1 parent 669f263 commit 3d19639

File tree

1 file changed

+14
-7
lines changed

1 file changed

+14
-7
lines changed

datasource/featuredb/featuredb.go

Lines changed: 14 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -81,13 +81,20 @@ func (f *FeatureDBClient) backgroundCheckVpcAddress() {
8181

8282
func (f *FeatureDBClient) CheckVpcAddress() {
8383
req, err := http.NewRequest("GET", fmt.Sprintf("%s/health", f.vpcAddress), nil)
84-
if err == nil {
85-
req.Header.Set("Content-Type", "application/json")
86-
resp, err := f.Client.Do(req)
87-
if err == nil && resp.StatusCode == http.StatusOK {
88-
f.useVpcAddress.Store(true)
89-
return
90-
}
84+
if err != nil {
85+
f.useVpcAddress.Store(false)
86+
return
87+
}
88+
req.Header.Set("Content-Type", "application/json")
89+
resp, err := f.Client.Do(req)
90+
if err != nil {
91+
f.useVpcAddress.Store(false)
92+
return
93+
}
94+
defer resp.Body.Close()
95+
if resp.StatusCode == http.StatusOK {
96+
f.useVpcAddress.Store(true)
97+
return
9198
}
9299

93100
f.useVpcAddress.Store(false)

0 commit comments

Comments
 (0)