From d78b39479a839b2e54081158f5d609017faeb02b Mon Sep 17 00:00:00 2001 From: Damien de Lemeny Date: Mon, 15 Apr 2024 09:19:59 -0500 Subject: [PATCH] Avoid resource leak in timestamp_infos --- pkg/quickwit/timestamp_infos.go | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/pkg/quickwit/timestamp_infos.go b/pkg/quickwit/timestamp_infos.go index e3b3de8..4237076 100644 --- a/pkg/quickwit/timestamp_infos.go +++ b/pkg/quickwit/timestamp_infos.go @@ -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 @@ -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()) @@ -83,6 +83,7 @@ func GetTimestampFieldFromIndexPattern(indexPattern string, qwickwitUrl string, qwlog.Error(errMsg) return "", "", err } + defer r.Body.Close() statusCode := r.StatusCode @@ -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())