Merge pull request #510 from andrewgaul/close-streams

Close streams on error paths
This commit is contained in:
Adrian Cole 2012-03-22 13:07:44 -07:00
commit 2a4bcf83b0
3 changed files with 3 additions and 5 deletions

View File

@ -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))

View File

@ -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();
}

View File

@ -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();
}