Signed-off-by: Antonio Murdaca <runcom@redhat.com>
| ... | ... |
@@ -236,6 +236,7 @@ func (cli *DockerCli) CmdBuild(args ...string) error {
|
| 236 | 236 |
if err != nil {
|
| 237 | 237 |
return err |
| 238 | 238 |
} |
| 239 |
+ defer response.Body.Close() |
|
| 239 | 240 |
|
| 240 | 241 |
err = jsonmessage.DisplayJSONMessagesStream(response.Body, buildBuff, cli.outFd, cli.isTerminalOut, nil) |
| 241 | 242 |
if err != nil {
|
| ... | ... |
@@ -174,9 +174,7 @@ func (l *splunkLogger) Log(msg *logger.Message) error {
|
| 174 | 174 |
if err != nil {
|
| 175 | 175 |
return err |
| 176 | 176 |
} |
| 177 |
- if res.Body != nil {
|
|
| 178 |
- defer res.Body.Close() |
|
| 179 |
- } |
|
| 177 |
+ defer res.Body.Close() |
|
| 180 | 178 |
if res.StatusCode != http.StatusOK {
|
| 181 | 179 |
var body []byte |
| 182 | 180 |
body, err = ioutil.ReadAll(res.Body) |
| ... | ... |
@@ -101,6 +101,7 @@ func (c *Client) SendFile(serviceMethod string, data io.Reader, ret interface{})
|
| 101 | 101 |
if err != nil {
|
| 102 | 102 |
return err |
| 103 | 103 |
} |
| 104 |
+ defer body.Close() |
|
| 104 | 105 |
if err := json.NewDecoder(body).Decode(&ret); err != nil {
|
| 105 | 106 |
logrus.Errorf("%s: error reading plugin resp: %v", serviceMethod, err)
|
| 106 | 107 |
return err |
| ... | ... |
@@ -284,6 +284,7 @@ func (r *Session) GetRemoteImageLayer(imgID, registry string, imgSize int64) (io |
| 284 | 284 |
res, err = r.client.Do(req) |
| 285 | 285 |
if err != nil {
|
| 286 | 286 |
logrus.Debugf("Error contacting registry %s: %v", registry, err)
|
| 287 |
+ // the only case err != nil && res != nil is https://golang.org/src/net/http/client.go#L515 |
|
| 287 | 288 |
if res != nil {
|
| 288 | 289 |
if res.Body != nil {
|
| 289 | 290 |
res.Body.Close() |