Skip to content

Commit

Permalink
Merge pull request #120 from quickwit-oss/ddelemeny/fix-body-close
Browse files Browse the repository at this point in the history
Avoid resource leak in timestamp_infos
  • Loading branch information
ddelemeny authored Apr 15, 2024
2 parents 643f90d + d78b394 commit fe3e009
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions pkg/quickwit/timestamp_infos.go
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,7 @@ func GetTimestampFieldFromIndex(index string, qwickwitUrl string, cli *http.Clie
qwlog.Error(errMsg)
return "", "", err
}
defer r.Body.Close()

statusCode := r.StatusCode

Expand All @@ -63,7 +64,6 @@ func GetTimestampFieldFromIndex(index string, qwickwitUrl string, cli *http.Clie
return "", "", NewErrorCreationPayload(statusCode, errMsg)
}

defer r.Body.Close()
body, err := io.ReadAll(r.Body)
if err != nil {
errMsg := fmt.Sprintf("Error when calling url = %s: err = %s", mappingEndpointUrl, err.Error())
Expand All @@ -83,6 +83,7 @@ func GetTimestampFieldFromIndexPattern(indexPattern string, qwickwitUrl string,
qwlog.Error(errMsg)
return "", "", err
}
defer r.Body.Close()

statusCode := r.StatusCode

Expand All @@ -92,7 +93,6 @@ func GetTimestampFieldFromIndexPattern(indexPattern string, qwickwitUrl string,
return "", "", NewErrorCreationPayload(statusCode, errMsg)
}

defer r.Body.Close()
body, err := io.ReadAll(r.Body)
if err != nil {
errMsg := fmt.Sprintf("Error when calling url = %s: err = %s", mappingEndpointUrl, err.Error())
Expand Down

0 comments on commit fe3e009

Please sign in to comment.