Skip to content

Commit

Permalink
fix: r.v as io.Closer should always close
Browse files Browse the repository at this point in the history
  • Loading branch information
morlay committed Jan 11, 2025
1 parent e7e7b35 commit 1a0a06c
Showing 1 changed file with 4 additions and 0 deletions.
4 changes: 4 additions & 0 deletions pkg/courierhttp/payload.go
Original file line number Diff line number Diff line change
Expand Up @@ -201,6 +201,10 @@ func (r *response[T]) Meta() courier.Metadata {

func (r *response[T]) WriteResponse(ctx context.Context, rw http.ResponseWriter, req RequestInfo) (finalErr error) {
defer func() {
if x, ok := r.v.(io.Closer); ok {
// close again to avoid some leak issue
_ = x.Close()
}
r.v = nil
if finalErr != nil {
logr.FromContext(ctx).Error(finalErr)
Expand Down

0 comments on commit 1a0a06c

Please sign in to comment.