javaswift / joss

Java library for OpenStack Storage, aka Swift
http://javaswift.org
117 stars 108 forks source link

Stop leaking connection when status code verification throws exception #144

Closed jeremy-l-ford closed 6 years ago

jeremy-l-ford commented 6 years ago

Per the apache documentation at https://hc.apache.org/httpcomponents-client-4.5.x/quickstart.html, one must consume the entity to avoid leaking a connection. When attempting to execute a download command, the entity will not be automatically closed. However, if the download command's status fails verification (ex: 404), then an exception is received by the client and the client does not have a chance to use the InputStream and close it. This PR will close the entity if statusCodeVerification has failed.