summaryrefslogtreecommitdiff
path: root/client/volume_remove.go
diff options
context:
space:
mode:
authorSebastiaan van Stijn <github@gone.nl>2019-02-11 13:26:12 +0100
committerSebastiaan van Stijn <github@gone.nl>2019-03-18 15:26:21 +0100
commit9c846b2fccfbd27062e91596106630175a4780c5 (patch)
tree77d57ccd2e09bde52ff87ce109d5a350afd7324e /client/volume_remove.go
parent38005cfc12fb6bdcff359c25e8fe05f2944b0d49 (diff)
downloaddocker-9c846b2fccfbd27062e91596106630175a4780c5.tar.gz
Client: always call ensureReaderClosed
Unlike a plain `net/http/client.Do()`, requests made through client/request use the `sendRequest` function, which parses the server response, and may convert non-transport errors into errors (through `cli.checkResponseErr()`). This means that we cannot assume that no reader was opened if an error is returned. This patch changes various locations where `ensureReaderClosed` was only called in the non-error situation, and uses a `defer` to make sure it's always called. `ensureReaderClosed` itself already checks if the response's body was set, so in situations where the error was due to a transport error, calling `ensureReaderClosed` should be a no-op. Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
Diffstat (limited to 'client/volume_remove.go')
-rw-r--r--client/volume_remove.go2
1 files changed, 1 insertions, 1 deletions
diff --git a/client/volume_remove.go b/client/volume_remove.go
index fc5a71d334..79decdafab 100644
--- a/client/volume_remove.go
+++ b/client/volume_remove.go
@@ -16,6 +16,6 @@ func (cli *Client) VolumeRemove(ctx context.Context, volumeID string, force bool
}
}
resp, err := cli.delete(ctx, "/volumes/"+volumeID, query, nil)
- ensureReaderClosed(resp)
+ defer ensureReaderClosed(resp)
return wrapResponseError(err, resp, "volume", volumeID)
}