Skip to content

Commit

Permalink
Merge branch 'main' into refactor/xdg-go
Browse files Browse the repository at this point in the history
  • Loading branch information
kruskall authored Jun 13, 2024
2 parents 9cc12ac + eadec29 commit d0063d7
Show file tree
Hide file tree
Showing 4 changed files with 10 additions and 6 deletions.
2 changes: 2 additions & 0 deletions .buildkite/pipeline.yml
Original file line number Diff line number Diff line change
Expand Up @@ -116,6 +116,7 @@ steps:
- .buildkite/x-pack/pipeline.xpack.filebeat.yml
- .buildkite/scripts
- .buildkite/hooks/
- .buildkite/deploy/docker/docker-compose.yml
#OSS
- go.mod
- pytest.ini
Expand Down Expand Up @@ -219,6 +220,7 @@ steps:
- .buildkite/x-pack/pipeline.xpack.metricbeat.yml
- .buildkite/scripts
- .buildkite/hooks/
- .buildkite/deploy/docker/docker-compose.yml
#OSS
- go.mod
- pytest.ini
Expand Down
1 change: 1 addition & 0 deletions CHANGELOG-developer.next.asciidoc
Original file line number Diff line number Diff line change
Expand Up @@ -100,6 +100,7 @@ The list below covers the major changes between 7.0.0-rc2 and main only.
- Skip flakey metrics test on windows in filebeat httpjson input. {issue}39676[39676] {pull}39678[39678]
- Fix flakey test on Windows 2022 in packetbeat/route. {issue}39698[39698] {pull}39822[39822]
- Fix bug in minimum length for request trace logging. {pull}39834[39834]
- Close connections properly in Filbeat's HTTPJSON input. {pull}39790[39790]

==== Added

Expand Down
6 changes: 6 additions & 0 deletions x-pack/filebeat/input/httpjson/policy.go
Original file line number Diff line number Diff line change
Expand Up @@ -91,6 +91,12 @@ func (p *Policy) CustomRetryPolicy(ctx context.Context, resp *http.Response, err
// errors and may relate to outages on the server side. This will catch
// invalid response codes as well, like 0 and 999.
if resp.StatusCode == 0 || (resp.StatusCode >= 500 && resp.StatusCode != 501) {
defer func() {
if resp.Body != nil {
_, _ = io.Copy(io.Discard, resp.Body)
resp.Body.Close()
}
}()
return true, nil
}

Expand Down
7 changes: 1 addition & 6 deletions x-pack/filebeat/input/httpjson/request.go
Original file line number Diff line number Diff line change
Expand Up @@ -676,6 +676,7 @@ func (r *requester) processChainPaginationEvents(ctx context.Context, trCtx *tra
if err != nil {
return -1, fmt.Errorf("failed to collect response: %w", err)
}

// store data according to response type
if i == len(r.requestFactories)-1 && len(ids) != 0 {
finalResps = append(finalResps, httpResp)
Expand All @@ -702,12 +703,6 @@ func (r *requester) processChainPaginationEvents(ctx context.Context, trCtx *tra
n += p.eventCount()
}

defer func() {
if httpResp != nil && httpResp.Body != nil {
httpResp.Body.Close()
}
}()

return n, nil
}

Expand Down

0 comments on commit d0063d7

Please sign in to comment.