From e145c3be77d4ad0bd4a6ab44a95e1f1248189ae3 Mon Sep 17 00:00:00 2001 From: Benedikt Kulmann Date: Mon, 5 Oct 2020 12:22:30 +0200 Subject: [PATCH] Handle error on response.Body.Close() --- accounts/pkg/storage/cs3.go | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/accounts/pkg/storage/cs3.go b/accounts/pkg/storage/cs3.go index c930cba2bab..d8b1c7fc978 100644 --- a/accounts/pkg/storage/cs3.go +++ b/accounts/pkg/storage/cs3.go @@ -92,12 +92,14 @@ func (r CS3Repo) LoadAccount(ctx context.Context, id string, a *proto.Account) ( return ¬FoundErr{"account", id} } - defer resp.Body.Close() dec := json.NewDecoder(resp.Body) var b []byte if err = dec.Decode(&b); err != nil { return err } + if err = resp.Body.Close(); err != nil { + return err + } return json.Unmarshal(b, &a) } @@ -165,12 +167,14 @@ func (r CS3Repo) LoadGroup(ctx context.Context, id string, g *proto.Group) (err return ¬FoundErr{"group", id} } - defer resp.Body.Close() dec := json.NewDecoder(resp.Body) var b []byte if err = dec.Decode(&b); err != nil { return err } + if err = resp.Body.Close(); err != nil { + return err + } return json.Unmarshal(b, &g) }