Skip to content

Commit

Permalink
fix: codecs.GZIP checks error before defer func (#730)
Browse files Browse the repository at this point in the history
  • Loading branch information
bmoylan authored Dec 5, 2024
1 parent b7248da commit e2d5bcd
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 3 deletions.
5 changes: 5 additions & 0 deletions changelog/@unreleased/pr-730.v2.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
type: fix
fix:
description: Codecs.GZIP checks error before defer func
links:
- https://github.com/palantir/conjure-go-runtime/pull/730
6 changes: 3 additions & 3 deletions conjure-go-contract/codecs/gzip.go
Original file line number Diff line number Diff line change
Expand Up @@ -38,14 +38,14 @@ func (c codecGZIP) Accept() string {

func (c codecGZIP) Decode(r io.Reader, v interface{}) (err error) {
gzipReader, err := gzip.NewReader(r)
if err != nil {
return fmt.Errorf("failed to create gzip reader: %w", err)
}
defer func() {
if closeErr := gzipReader.Close(); err == nil && closeErr != nil {
err = closeErr
}
}()
if err != nil {
return fmt.Errorf("failed to create gzip reader: %s", err.Error())
}
return c.contentCodec.Decode(gzipReader, v)
}

Expand Down

0 comments on commit e2d5bcd

Please sign in to comment.