Skip to content

client: RoundTrip should not close the request body, when there is no logger defined #150

@kayrus

Description

@kayrus

Currently the request body is closed even, when the logger is not defined:

utils/client/client.go

Lines 149 to 153 in f6de111

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

It should be closed only when the logger is defined, e.g.:

        defer func() {
                if rt.Logger != nil && request.Body != nil {
                        request.Body.Close()
                }
        }()

AFAIK it is not a big deal, because in most cases original RoundTrip closes the request body, but I think there could rare cases with bad connection, when this is not happened and this can lead to a memory leak.

@jtopjian objections, anything to add?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions