From 36592d33ad688fefe779e0bf018670c0436d3caa Mon Sep 17 00:00:00 2001 From: efilipowicz <45579436+efilipowicz@users.noreply.github.com> Date: Wed, 11 Jun 2025 14:19:55 -0400 Subject: [PATCH] Prevent HTTP connection leak on network exceptions --- .../com/smartsheet/api/internal/http/DefaultHttpClient.java | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/main/java/com/smartsheet/api/internal/http/DefaultHttpClient.java b/src/main/java/com/smartsheet/api/internal/http/DefaultHttpClient.java index b0ae28ea9..7cdad4df1 100644 --- a/src/main/java/com/smartsheet/api/internal/http/DefaultHttpClient.java +++ b/src/main/java/com/smartsheet/api/internal/http/DefaultHttpClient.java @@ -288,6 +288,7 @@ public HttpResponse request(HttpRequest smartsheetRequest) throws HttpClientExce this.releaseConnection(); } catch (ClientProtocolException e) { + this.releaseConnection(); logger.warn("ClientProtocolException " + e.getMessage()); logger.warn(LOG_ARG, RequestAndResponseData.of(apacheHttpRequest, requestEntityCopy, smartsheetResponse, responseEntityCopy, REQUEST_RESPONSE_SUMMARY)); @@ -305,6 +306,7 @@ public HttpResponse request(HttpRequest smartsheetRequest) throws HttpClientExce } throw new HttpClientException(ERROR_OCCURRED, e); } catch (NoHttpResponseException e) { + this.releaseConnection(); logger.warn("NoHttpResponseException {}", e.getMessage()); logger.warn(LOG_ARG, RequestAndResponseData.of(apacheHttpRequest, requestEntityCopy, smartsheetResponse, responseEntityCopy, REQUEST_RESPONSE_SUMMARY)); @@ -322,6 +324,7 @@ public HttpResponse request(HttpRequest smartsheetRequest) throws HttpClientExce } throw new HttpClientException(ERROR_OCCURRED, e); } catch (IOException e) { + this.releaseConnection(); logger.warn(LOG_ARG, RequestAndResponseData.of(apacheHttpRequest, requestEntityCopy, smartsheetResponse, responseEntityCopy, REQUEST_RESPONSE_SUMMARY)); throw new HttpClientException(ERROR_OCCURRED, e);