mirror of https://github.com/apache/jclouds.git
Merge pull request #510 from andrewgaul/close-streams
Close streams on error paths
This commit is contained in:
commit
2a4bcf83b0
|
@ -156,6 +156,7 @@ public abstract class BaseHttpCommandExecutorService<Q> implements HttpCommandEx
|
|||
utils.logResponse(headerLog, response, "<<");
|
||||
if (response.getPayload() != null && wire.enabled())
|
||||
wire.input(response);
|
||||
nativeRequest = null; // response took ownership of streams
|
||||
int statusCode = response.getStatusCode();
|
||||
if (statusCode >= 300) {
|
||||
if (shouldContinue(response))
|
||||
|
|
|
@ -255,12 +255,9 @@ public class JavaUrlHttpCommandExecutorService extends BaseHttpCommandExecutorSe
|
|||
|
||||
}
|
||||
|
||||
/**
|
||||
* Only disconnect if there is no content, as disconnecting will throw away unconsumed content.
|
||||
*/
|
||||
@Override
|
||||
protected void cleanup(HttpURLConnection connection) {
|
||||
if (connection != null && connection.getContentLength() == 0)
|
||||
if (connection != null)
|
||||
connection.disconnect();
|
||||
}
|
||||
|
||||
|
|
|
@ -201,7 +201,7 @@ public abstract class BaseRestClientExpectTest<S> {
|
|||
|
||||
@Override
|
||||
public void cleanup(HttpRequest nativeResponse) {
|
||||
if (nativeResponse.getPayload() != null)
|
||||
if (nativeResponse != null && nativeResponse.getPayload() != null)
|
||||
nativeResponse.getPayload().release();
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue