From 4e70b69d1bc73e31324d6d46327efd5d2fd94f05 Mon Sep 17 00:00:00 2001 From: ShourieG <105607378+ShourieG@users.noreply.github.com> Date: Wed, 28 Dec 2022 10:47:57 +0530 Subject: [PATCH] [filebeat][httpjson]- improved error handling during pagination with chaining & split processor (#34127) * added a safety check to avoid unnecessary panics * updated asciidoc * updated asciidoc --- CHANGELOG.next.asciidoc | 1 + x-pack/filebeat/input/httpjson/request.go | 7 ++++++- 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.next.asciidoc b/CHANGELOG.next.asciidoc index c960bf88dcd..889063a9dc8 100644 --- a/CHANGELOG.next.asciidoc +++ b/CHANGELOG.next.asciidoc @@ -51,6 +51,7 @@ https://github.com/elastic/beats/compare/v8.2.0\...main[Check the HEAD diff] *Filebeat* +- [httpsjon] Improved error handling during pagination with chaining & split processor {pull}34127[34127] - [Azure blob storage] Added support for more mime types & introduced offset tracking via cursor state. {pull}33981[33981] - Fix EOF on single line not producing any event. {issue}30436[30436] {pull}33568[33568] - Fix handling of error in states in direct aws-s3 listing input {issue}33513[33513] {pull}33722[33722] diff --git a/x-pack/filebeat/input/httpjson/request.go b/x-pack/filebeat/input/httpjson/request.go index 30ab23b8a44..3a04d0a3d72 100644 --- a/x-pack/filebeat/input/httpjson/request.go +++ b/x-pack/filebeat/input/httpjson/request.go @@ -667,7 +667,12 @@ func (r *requester) processChainPaginationEvents(stdCtx context.Context, trCtx * n += processAndPublishEvents(chainTrCtx, events, publisher, i < len(r.requestFactories), r.log) } - defer httpResp.Body.Close() + defer func() { + if httpResp != nil && httpResp.Body != nil { + httpResp.Body.Close() + } + }() + return n, nil }