From a52e4eb56c3a15c58f6f3cfb4b115330661aae57 Mon Sep 17 00:00:00 2001 From: Adam Shannon Date: Fri, 21 Jul 2023 14:19:30 -0500 Subject: [PATCH] fix: close xml encoder --- pkg/client/client.go | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/pkg/client/client.go b/pkg/client/client.go index 2228d8f6..e172ef3b 100644 --- a/pkg/client/client.go +++ b/pkg/client/client.go @@ -447,7 +447,11 @@ func setBody(body interface{}, contentType string) (bodyBuf *bytes.Buffer, err e } else if jsonCheck.MatchString(contentType) { err = json.NewEncoder(bodyBuf).Encode(body) } else if xmlCheck.MatchString(contentType) { - err = xml.NewEncoder(bodyBuf).Encode(body) + enc := xml.NewEncoder(bodyBuf) + err = enc.Encode(body) + if closeErr := enc.Close(); closeErr != nil { + err = fmt.Errorf("%v: close error %v", err, closeErr) + } } if err != nil {