Skip to content

Commit

Permalink
Address review comments
Browse files Browse the repository at this point in the history
  • Loading branch information
shmsr committed Jun 4, 2024
1 parent 417ce7e commit 10a03bb
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 6 deletions.
1 change: 1 addition & 0 deletions x-pack/filebeat/input/httpjson/policy.go
Original file line number Diff line number Diff line change
Expand Up @@ -93,6 +93,7 @@ func (p *Policy) CustomRetryPolicy(ctx context.Context, resp *http.Response, err
if resp.StatusCode == 0 || (resp.StatusCode >= 500 && resp.StatusCode != 501) {
defer func() {
if resp.Body != nil {
io.Copy(io.Discard, resp.Body)

Check failure on line 96 in x-pack/filebeat/input/httpjson/policy.go

View workflow job for this annotation

GitHub Actions / lint (windows)

Error return value of `io.Copy` is not checked (errcheck)
resp.Body.Close()
}
}()
Expand Down
8 changes: 2 additions & 6 deletions x-pack/filebeat/input/httpjson/request.go
Original file line number Diff line number Diff line change
Expand Up @@ -618,6 +618,7 @@ func (r *requester) processChainPaginationEvents(ctx context.Context, trCtx *tra
err error
urlCopy url.URL
urlString string
httpResp *http.Response
intermediateResps []*http.Response
finalResps []*http.Response
)
Expand Down Expand Up @@ -671,15 +672,10 @@ func (r *requester) processChainPaginationEvents(ctx context.Context, trCtx *tra
}

// collect data from new urls
httpResp, err := rf.collectResponse(ctx, chainTrCtx, r)
httpResp, err = rf.collectResponse(ctx, chainTrCtx, r)
if err != nil {
return -1, fmt.Errorf("failed to collect response: %w", err)
}
defer func() {
if httpResp != nil && httpResp.Body != nil {
httpResp.Body.Close()
}
}()

// store data according to response type
if i == len(r.requestFactories)-1 && len(ids) != 0 {
Expand Down

0 comments on commit 10a03bb

Please sign in to comment.