From 8a35cb57fac2b889b266c1789425e5f45974a848 Mon Sep 17 00:00:00 2001 From: Selene Date: Wed, 19 Oct 2022 19:20:03 +0200 Subject: [PATCH] Fix null pointer (#57292) --- pkg/services/querylibrary/tests/api_client.go | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/pkg/services/querylibrary/tests/api_client.go b/pkg/services/querylibrary/tests/api_client.go index 99ab74f8334..ec7a769ec33 100644 --- a/pkg/services/querylibrary/tests/api_client.go +++ b/pkg/services/querylibrary/tests/api_client.go @@ -53,11 +53,12 @@ func (q *queryLibraryAPIClient) update(ctx context.Context, query *querylibrary. req.Header.Set("Content-Type", "application/json") client := &http.Client{} resp, err := client.Do(req) - defer func() { - _ = resp.Body.Close() - }() + if err != nil { + return err + } - return err + _ = resp.Body.Close() + return nil } func (q *queryLibraryAPIClient) delete(ctx context.Context, uid string) error {