From 3550f817dce7a47a767341cd16801e6160abf918 Mon Sep 17 00:00:00 2001 From: andrey-qlogic Date: Thu, 29 Nov 2018 10:37:33 +0000 Subject: [PATCH] 4107: Close response body after request --- .../com/google/cloud/storage/spi/v1/HttpStorageRpc.java | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/google-cloud-clients/google-cloud-storage/src/main/java/com/google/cloud/storage/spi/v1/HttpStorageRpc.java b/google-cloud-clients/google-cloud-storage/src/main/java/com/google/cloud/storage/spi/v1/HttpStorageRpc.java index 19c9324518d7..5653e6a42d4b 100644 --- a/google-cloud-clients/google-cloud-storage/src/main/java/com/google/cloud/storage/spi/v1/HttpStorageRpc.java +++ b/google-cloud-clients/google-cloud-storage/src/main/java/com/google/cloud/storage/spi/v1/HttpStorageRpc.java @@ -681,14 +681,19 @@ public void write(String uploadId, byte[] toWrite, int toWriteOffset, long destO int code; String message; IOException exception = null; + HttpResponse response = null; try { - HttpResponse response = httpRequest.execute(); + response = httpRequest.execute(); code = response.getStatusCode(); message = response.getStatusMessage(); } catch (HttpResponseException ex) { exception = ex; code = ex.getStatusCode(); message = ex.getStatusMessage(); + } finally { + if (response != null ) { + response.disconnect(); + } } if (!last && code != 308 || last && !(code == 200 || code == 201)) { if (exception != null) {